Skip to content
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: do not overwrite error when creating context #26112

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ MaybeLocal<Context> ContextifyContext::CreateV8Context(
Local<Context> ctx = NewContext(env->isolate(), object_template);

if (ctx.IsEmpty()) {
env->ThrowError("Could not instantiate context");
return MaybeLocal<Context>();
}

Expand Down
17 changes: 17 additions & 0 deletions test/parallel/test-worker-vm-context-terminate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const vm = require('vm');
const { Worker } = require('worker_threads');

// Do not use isMainThread so that this test itself can be run inside a Worker.
if (!process.env.HAS_STARTED_WORKER) {
process.env.HAS_STARTED_WORKER = 1;
const w = new Worker(__filename);
setTimeout(() => w.terminate(), 50);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is using the 'online' event here instead an option?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjihrig I’ve added that but kept the timeout, it still seems to make this fail more reliably locally (with the node master executable).

w.on('error', common.mustNotCall());
w.on('exit', common.mustCall((code) => assert.strictEqual(code, 1)));
} else {
while (true)
vm.runInNewContext('');
}