Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unahndled Exception when a request is aborted #1638

mac- opened this issue May 16, 2014 · 1 comment

Unahndled Exception when a request is aborted #1638

mac- opened this issue May 16, 2014 · 1 comment


Copy link

@mac- mac- commented May 16, 2014

Env Details

OS: Ubuntu 12.04
Node Version: 0.10.21
Hapi Version: ^4.1.1 (I cannot reproduce this on 4.1.0 or 4.0.x)

Example Code

Below is an example server that will cause an exception to be thrown and kill the node process when a request is aborted:


var Hapi = require('hapi'),
    server = Hapi.createServer('', 8080);

    method: 'GET',
    path: '/fnord',
    handler: function(req, reply) { setTimeout(reply, 60000); }

server.ext('onPreResponse', function (request, reply) {
    return reply();

server.start(function() {
    console.log('Server started at:',;

Here is the stack trace:

    throw new Error(msgs.join(' ') || 'Unknown error');
Error: Invalid nested use of
    at Object.exports.assert (/home/user/projects/hapi-test/node_modules/hapi/node_modules/hoek/lib/index.js:349:11)
    at (/home/user/projects/hapi-test/node_modules/hapi/lib/protect.js:37:11)
    at Object.exports.invoke (/home/user/projects/hapi-test/node_modules/hapi/lib/handler.js:370:22)
    at internals.Request._reply (/home/user/projects/hapi-test/node_modules/hapi/lib/request.js:346:13)
    at IncomingMessage._onClose (/home/user/projects/hapi-test/node_modules/hapi/lib/request.js:126:14)
    at IncomingMessage.g (events.js:175:14)
    at IncomingMessage.EventEmitter.emit (events.js:92:17)
    at abortIncoming (http.js:1912:11)
    at Socket.socket.onend (http.js:2010:7)
    at Socket.g (events.js:175:14)

Steps to Reproduce

  1. Start the server: node app.js
  2. Issue a request to the /fnord endpoint: curl http://localhost:8080/fnord
  3. Issue a SIGINT signal (CTRL+C) to the above curl command to abort the request within the next minute


The issue can be avoided by removing the onPreResponse extension handler.

@hueniverse hueniverse added the bug label May 17, 2014
@hueniverse hueniverse self-assigned this May 17, 2014
@hueniverse hueniverse added this to the 4.1.3 milestone May 17, 2014
@hueniverse hueniverse reopened this May 17, 2014
Copy link

@hueniverse hueniverse commented May 17, 2014

Fails on 0.10 (works on 0.11)

@hueniverse hueniverse added this to the 4.1.4 milestone May 17, 2014
@hueniverse hueniverse removed this from the 4.1.3 milestone May 17, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Jan 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants