summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-catch-uncaughtexception.js
diff options
context:
space:
mode:
authorTrevor Norris <trev.norris@gmail.com>2016-03-04 15:14:27 -0700
committerTrevor Norris <trev.norris@gmail.com>2016-03-08 10:45:58 -0700
commit3521b052b175110aab08fe6296e7d5cffbb72925 (patch)
treebb26429e6b0b8f6bcca51d55b9a3116718a9e0b1 /test/parallel/test-http-catch-uncaughtexception.js
parent4ed038808f7bb78cc00fce6162b3f71b45abbd66 (diff)
downloadandroid-node-v8-3521b052b175110aab08fe6296e7d5cffbb72925.tar.gz
android-node-v8-3521b052b175110aab08fe6296e7d5cffbb72925.tar.bz2
android-node-v8-3521b052b175110aab08fe6296e7d5cffbb72925.zip
src,http: fix uncaughtException miss in http
In AsyncWrap::MakeCallback always return empty handle if there is an error. In the future this should change to return a v8::MaybeLocal, but that major change will have to wait for v6.x, and these changes are meant to be backported to v4.x. The HTTParser call to AsyncWrap::MakeCallback failed because it expected a thrown call to return an empty handle. In node::MakeCallback return an empty handle if the call is in_makecallback(), otherwise return v8::Undefined() as usual to preserve backwards compatibility. Fixes: https://github.com/nodejs/node/issues/5555 PR-URL: https://github.com/nodejs/node/pull/5591 Reviewed-By: Julien Gilli <jgilli@nodejs.org>
Diffstat (limited to 'test/parallel/test-http-catch-uncaughtexception.js')
-rw-r--r--test/parallel/test-http-catch-uncaughtexception.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/parallel/test-http-catch-uncaughtexception.js b/test/parallel/test-http-catch-uncaughtexception.js
new file mode 100644
index 0000000000..c4054aafbf
--- /dev/null
+++ b/test/parallel/test-http-catch-uncaughtexception.js
@@ -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();
+ });
+});