You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
node:vm microtaskMode: 'afterEvaluate' doesn't seem to be respected #20145
I am not sure if this can even be fixed without changes to JSC because JSC does not have context specific micro task queues, you only have access to vm.drainMicrotasks() which is obviously a global queue which means the Microtask outside VM promise will be ahead in the queue relative to the Microtask inside VM that is created later.
Hello! I've seen the recent improvements for node:vm in the Bun 1.3 changelog. Could you please clarify if this issue regarding microtaskMode: 'afterEvaluate' was addressed as part of those changes? I haven't had a chance to test it myself yet. Thanks!
Verified on main at df84f8d: microtaskMode: 'afterEvaluate' now drains the VM context's microtasks before vm.runInContext returns, matching Node.js ordering.
$ bun repro.js
Before vm.runInContext
End of VM code
Microtask inside VM
After vm.runInContext
Microtask outside VM
Activity
nhattran998 commentedon Jun 4, 2025
+1 for the same issue
Jarred-Sumner commentedon Jun 4, 2025
can you explain the usecase more?
d2201 commentedon Jun 4, 2025
@Jarred-Sumner the tool I'm using (temporal.io) depends on VM to deliver it's core functionality.
At a high level, the workflow looks like this:
This works flawlessly in Node.js. However, in Bun, it fails -- the information sent to the control server ends up being empty.
This is the long-standing issue we're trying to resolve: temporalio/sdk-typescript#1334
x04 commentedon Jul 30, 2025
I am not sure if this can even be fixed without changes to JSC because JSC does not have context specific micro task queues, you only have access to
vm.drainMicrotasks()which is obviously a global queue which means theMicrotask outside VMpromise will be ahead in the queue relative to theMicrotask inside VMthat is created later.kunalsinghal commentedon Aug 13, 2025
+1 to the issue; we're sadly forced to temporarily move to node because of this issue
Tanner-Scadden commentedon Sep 8, 2025
+1 to this issue, we have to deploy to node until this is fixed, and use vitest for the test suite, vs being able to do it all through bun.
matvejs16 commentedon Oct 11, 2025
Hello! I've seen the recent improvements for
node:vmin the Bun 1.3 changelog. Could you please clarify if this issue regardingmicrotaskMode: 'afterEvaluate'was addressed as part of those changes? I haven't had a chance to test it myself yet. Thanks!vm.runInContextbehaves different than Node.js #24267 as a duplicate of this issueyordis commentedon Jan 22, 2026
temporalio/sdk-typescript#1334 is blocking us as well
@matvejs16 I think I did-did tested in latest bun and it was still an issue, but I will confirm in 2 weeks once I am back home.
robobun commentedon Jul 24, 2026
Fixed by #32018.
Verified on main at df84f8d:
microtaskMode: 'afterEvaluate'now drains the VM context's microtasks beforevm.runInContextreturns, matching Node.js ordering.