summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-timeout-client-warning.js
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-02-21 17:52:35 +0100
committerAnna Henningsen <anna@addaleax.net>2018-03-04 21:55:21 +0000
commit648d668fcc29dafeb99f90d89087b682457f96b3 (patch)
tree18b5aa896f2b4d868dd99588a89faf5b695607d9 /test/parallel/test-http-timeout-client-warning.js
parentd83f8303fdc5dc5c934df87f0883d1f2558b10a6 (diff)
downloadandroid-node-v8-648d668fcc29dafeb99f90d89087b682457f96b3.tar.gz
android-node-v8-648d668fcc29dafeb99f90d89087b682457f96b3.tar.bz2
android-node-v8-648d668fcc29dafeb99f90d89087b682457f96b3.zip
http: emit timeout duration overflow warning sync
Emit the `TimeoutOverflowWarning` synchronously, even when still connecting, to get a better stack trace. With thanks to Anatoli Papirovski for providing helpful tips when writing the test. PR-URL: https://github.com/nodejs/node/pull/18906 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-http-timeout-client-warning.js')
-rw-r--r--test/parallel/test-http-timeout-client-warning.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/parallel/test-http-timeout-client-warning.js b/test/parallel/test-http-timeout-client-warning.js
new file mode 100644
index 0000000000..f11515b95f
--- /dev/null
+++ b/test/parallel/test-http-timeout-client-warning.js
@@ -0,0 +1,21 @@
+'use strict';
+const common = require('../common');
+const http = require('http');
+const assert = require('assert');
+
+// Checks that the setTimeout duration overflow warning is emitted
+// synchronously and therefore contains a meaningful stacktrace.
+
+process.on('warning', common.mustCall((warning) => {
+ assert(warning.stack.includes(__filename));
+}));
+
+const server = http.createServer((req, resp) => resp.end());
+server.listen(common.mustCall(() => {
+ http.request(`http://localhost:${server.address().port}`)
+ .setTimeout(2 ** 40)
+ .on('response', common.mustCall(() => {
+ server.close();
+ }))
+ .end();
+}));