Push freezes if the handler is called in process.nextTick() #18

Closed
natesilva opened this Issue Mar 8, 2013 · 2 comments

Comments

Projects
None yet
2 participants
@natesilva

To reproduce: Take the example app shown on the pushover home page, and on line 19 simply wrap the handler in a process.nextTick():

//
// [example app from pushover home page; first part is the same]
//
var http = require('http');
var server = http.createServer(function (req, res) {
    process.nextTick(function() {
        repos.handle(req, res);
    });
});
server.listen(7005);

Run the app and push a repo to it.

Result: Starts to push, then hangs.

Not all requests hang, but a push often does.

This is preventing me from implementing auth. For example, if I auth to a database, the repos.handle method will get called later after some I/O has been done—equivalent to process.nextTick().

@juliangruber

This comment has been minimized.

Show comment Hide comment
@juliangruber

juliangruber Mar 8, 2013

Contributor

Could you try

var server = http.createServer(function (req, res) {
    req.pause();
    process.nextTick(function() {
        repos.handle(req, res);
        req.resume();
    });
});
Contributor

juliangruber commented Mar 8, 2013

Could you try

var server = http.createServer(function (req, res) {
    req.pause();
    process.nextTick(function() {
        repos.handle(req, res);
        req.resume();
    });
});
@natesilva

This comment has been minimized.

Show comment Hide comment
@natesilva

natesilva Mar 8, 2013

@juliangruber Thanks, that works. Looks like I have to read up some more on streams and pause()/resume().

@juliangruber Thanks, that works. Looks like I have to read up some more on streams and pause()/resume().

@natesilva natesilva closed this Mar 8, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment