Why is this simple node.js code freezing?

Here's an extension of the sample node.js code:

var express = require('express');
var application = express.createServer();

var redis = require("redis"),
    client = redis.createClient();

client.on("error", function (err) {
    console.log("Error " + err);
});

client.set("test key", "TEST KEY VALUE", redis.print);

application.get('/', function(request, response) {
        client.get('test key', function(err, value) {
            client.quit();
            response.send('The value of "test key" is: ' + value);
        });
});

application.listen(2455);

The server starts up fine, but when accessed, the page loads for a while eventually erroring out - "No data received."

I have redis running, the keys save fine, I can also access them via client.get() juts fine in node's repl.

I think I'm missing some theory on how async programs work.

I do not think Redis/redis libraries require you to kill the client connection explicitly. Even if you do, you need to ensure that the successful or error callbacks have been invoked & handled before quitting the client.

Hope it helps.

There is possibility that you receive an error, and because you are not checking err variable before res.send, your application returns nothing. Try to add something like: if(err) throw err; after client.get and check STDOUT