Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/async-wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
if (has_domain) {
domain = domain_v.As<Object>();
if (domain->Get(env()->disposed_string())->IsTrue())
return Undefined(env()->isolate());
return Local<Value>();
}
}

Expand All @@ -220,7 +220,7 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
}

if (ret.IsEmpty()) {
return Undefined(env()->isolate());
return ret;
}

if (has_domain) {
Expand Down Expand Up @@ -249,7 +249,7 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
}

if (env()->tick_callback_function()->Call(process, 0, nullptr).IsEmpty()) {
return Undefined(env()->isolate());
return Local<Value>();
}

return ret;
Expand Down
6 changes: 5 additions & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,11 @@ Local<Value> MakeCallback(Environment* env,
}

if (ret.IsEmpty()) {
return Undefined(env->isolate());
if (callback_scope.in_makecallback())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be useful to add a comment here mentioning that undefined is returned here for backward compatibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, just below.

return ret;
// NOTE: Undefined() is returned here for backwards compatibility.
else
return Undefined(env->isolate());
}

if (has_domain) {
Expand Down
23 changes: 23 additions & 0 deletions test/parallel/test-http-catch-uncaughtexception.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

const common = require('../common');
const assert = require('assert');
const http = require('http');

const uncaughtCallback = common.mustCall(function(er) {
assert.equal(er.message, 'get did fail');
});

process.on('uncaughtException', uncaughtCallback);

const server = http.createServer(function(req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('bye');
}).listen(common.PORT, function() {
http.get({ port: common.PORT }, function(res) {
res.resume();
throw new Error('get did fail');
}).on('close', function() {
server.close();
});
});