-
Notifications
You must be signed in to change notification settings - Fork 29.1k
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
vm writing to stderr #2373
Comments
@thefourtheye this is a bug, no? |
@thefourtheye I tested it out and I was editing and executing different files, I removed it. Sorry. |
This is interesting. try {
var vm = require('vm')
global.require = require
var code = [
'try {',
'require("missing")',
'} catch (e) {',
'throw e ',
'}'
].join('\n')
vm.createScript(code)
.runInNewContext(global)
} catch (e) {
} Writes
|
Ugg, it has nothing to do explicitly with try {
var vm = require('vm')
vm.createScript('throw new Error("hamburger")', "known")
.runInNewContext(global, "known")
} catch (e) {
}
|
The error is being caught properly without global... try {
var vm = require('vm')
vm.createScript('throw new Error("hamburger")', "known")
.runInNewContext({}, "known")
} catch (e) {
} |
Oh god, again :) |
I found a way to catch the trace, if you clone the require (specifically with lodash
|
Ug, didn't realize it said |
I dont get why half the thrown error is in the stack trace and half is written to stderr...... stderr
in stack trace
|
There's an option in vm, did the trick!!!!!!!!!! try {
var _ = require('lodash')
var vm = require('vm')
var sb = {}
sb.require = require
var script = new vm.Script("require('missing')")
script.runInNewContext(sb, {
displayErrors: false
})
} catch (e) {
throw e
} |
The issue is that the code below writes to stderr. Because it's wrapped in a try catch it shouldn't be writing to stderr.
It only writes this. Not even a complete throw w/ error stack trace.
I've tried to catch it with this, but it never fires.
The code example is here
The tests are here, it only started happening in version 11+.
The text was updated successfully, but these errors were encountered: