-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
repl: handle null thrown #14306
repl: handle null thrown #14306
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
require('../common'); | ||
const repl = require('repl'); | ||
const assert = require('assert'); | ||
const Stream = require('stream'); | ||
|
||
const output = new Stream(); | ||
let text = ''; | ||
output.write = output.pause = output.resume = function(buf) { | ||
text += buf.toString(); | ||
}; | ||
|
||
const replserver = repl.start({ | ||
output: output, | ||
input: process.stdin | ||
}); | ||
|
||
replserver.emit('line', 'process.nextTick(() => { throw null; })'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @TimothyGu yes, to reproduce the issue - without the nextTick it doesn't crash the REPL. |
||
replserver.emit('line', '.exit'); | ||
|
||
setTimeout(() => { | ||
console.log(text); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extraneous |
||
assert(text.includes('Thrown: null')); | ||
}, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not
process.binding('util').isNativeError
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TimothyGu Not sure that's the behaviour I'd want - I'd like people to (optimally) be able to override
Symbol.toStringTag
(or even the name) and take the "Error like" path if they really need to.I don't feel strongly about this though. If you do - let me know and I'll change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me.