| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 67b854d commit e4c164e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -195,7 +195,12 @@ function setupExceptionCapture() { | |||
| 195 | 195 | ||
| 196 | 196 | process.addUncaughtExceptionCaptureCallback((err) => { | |
| 197 | 197 | const store = replContext.getStore(); | |
| 198 | - if (store?.replServer && !store.replServer.closed) { | ||
| 198 | + // TODO(addaleax): Add back a `store.replServer.closed` check here | ||
| 199 | + // as a semver-major change. | ||
| 200 | + // This check may need to allow for an opt-out, since the change in | ||
| 201 | + // behavior could lead to DoS vulnerabilities (e.g. in the case of | ||
| 202 | + // the net-based REPL described in our docs). | ||
| 203 | + if (store?.replServer) { | ||
| 199 | 204 | store.replServer._handleError(err); | |
| 200 | 205 | return true; // We handled it | |
| 201 | 206 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,23 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const { start } = require('node:repl'); | ||
| 4 | + const { PassThrough } = require('node:stream'); | ||
| 5 | + const assert = require('node:assert'); | ||
| 6 | + | ||
| 7 | + // This test verifies that uncaught exceptions in the REPL | ||
| 8 | + // do not bring down the process, even if stdin may already | ||
| 9 | + // have been ended at that point (and the REPL closed as | ||
| 10 | + // a result of that). | ||
| 11 | + const input = new PassThrough(); | ||
| 12 | + const output = new PassThrough().setEncoding('utf8'); | ||
| 13 | + start({ | ||
| 14 | + input, | ||
| 15 | + output, | ||
| 16 | + terminal: false, | ||
| 17 | + }); | ||
| 18 | + | ||
| 19 | + input.end('setImmediate(() => { throw new Error("test"); });\n'); | ||
| 20 | + | ||
| 21 | + setImmediate(common.mustCall(() => { | ||
| 22 | + assert.match(output.read(), /Uncaught Error: test/); | ||
| 23 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments