Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Uncatchable client errors #3239

Closed
piscisaureus opened this issue May 8, 2012 · 3 comments
Closed

Uncatchable client errors #3239

piscisaureus opened this issue May 8, 2012 · 3 comments
Labels

Comments

@piscisaureus
Copy link

var net = require('net'),
    http = require('http');

var brokenServer = net.createServer(function(socket) {
  /* Write some broken headers. */
  socket.write('SNAFU/0.1 1337 broken response\r\n');
  socket.write('Content-Type: fubar\r\n');
  socket.write('\r\n');
  socket.write('Hello, moon\n');
  socket.destroySoon();

  socket.on('error', function() {});
});
brokenServer.listen(8000);

var options = {
  host: '127.0.0.1',
  port: 8000,
  path: '/index.html'
};

setInterval(function() {
  http.get(options, onResponse, onError);

  function onResponse(res) {
    console.log("Response:", res);
  }
  function onError(err) {
    console.log("Error:", err);
  }
}, 10);

process.on('uncaughtException', function(e) {
  console.log("Uncaught: ", e)
});

@bnoordhuis @isaacs <-- Calling the experts

@piscisaureus
Copy link
Author

CC @mranney

@bnoordhuis
Copy link
Member

There's a bug in your test. Try this:

diff --git a/test.js b/test.js
index 2cbcd81..9630809 100644
--- a/test.js
+++ b/test.js
@@ -20,7 +20,7 @@ var options = {
 };

 setInterval(function() {
-  http.get(options, onResponse, onError);
+  http.get(options, onResponse).on('error', onError);

   function onResponse(res) {
     console.log("Response:", res);

@isaacs
Copy link

isaacs commented May 10, 2012

Seems perhaps related to #3236?

shigeki pushed a commit to shigeki/node-v0.x-archive that referenced this issue Oct 16, 2015
Add SIGTRAP and the corresponding exit code to the list of signals/exit
codes that are expected when running tests that throw an uncaught error
and have --abort-on-uncaught-exception enabled.

Also refactor a bit related comments so that they better reflect what's
actually happening.

Fixes nodejs#3239.

PR: nodejs#3354
PR-URL: nodejs/node#3354
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
richardlau pushed a commit to ibmruntimes/node that referenced this issue Nov 5, 2015
Add SIGTRAP and the corresponding exit code to the list of signals/exit
codes that are expected when running tests that throw an uncaught error
and have --abort-on-uncaught-exception enabled.

Also refactor a bit related comments so that they better reflect what's
actually happening.

Fixes nodejs#3239.

PR: nodejs#3354
PR-URL: nodejs/node#3354
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants