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
// worker.mjsimport{isMainThread,Worker}from"node:worker_threads";if(isMainThread){// This re-loads the current file inside a Worker instance.constw=newWorker(import.meta.filename);}else{console.log("Inside Worker!");console.log(isMainThread);// Prints 'false'.}
$ deno run -A worker.mjs
Inside Worker!
false
$ node worker.mjs
Inside Worker!
false
Consider this script:
// worker.mjsimport{isMainThread,parentPort,Worker}from"node:worker_threads";if(isMainThread){// This re-loads the current file inside a Worker instance.constw=newWorker(import.meta.filename);}else{console.log("Inside Worker!");console.log(isMainThread);// Prints 'false'.parentPort.on("message",()=>console.log("Got message from main thread");}
$ deno run -A worker.mjs
Inside Worker!
false
# exits
$ node worker.mjs
Inside Worker!
false
# waits indefinitely
And this one:
// worker.mjsimport{isMainThread,parentPort,Worker}from"node:worker_threads";functiononMessageOneshot(){console.log("Got message from main thread!");parentPort.off("message",onMessageOneshot);}if(isMainThread){// This re-loads the current file inside a Worker instance.constw=newWorker(import.meta.filename);setTimeout(()=>{w.postMessage("Hello! I am from the main thread.");},1000);}else{console.log("Inside Worker!");console.log(isMainThread);// Prints 'false'.parentPort.on("message",onMessageOneshot);}
$ deno run -A worker.mjs
Inside Worker!
false
# exits
$ node worker.mjs
Inside Worker!
false
# waits 1s
Got message from main thread!
# exits
We need to fix condition for unrefing the op waiting for message inside a worker. We should only unref the op if there are no active message listeners.
Version: Deno 1.41.3
This bug was introduced in #22647.
Consider following script:
Consider this script:
And this one:
We need to fix condition for unrefing the op waiting for message inside a worker. We should only unref the op if there are no active message listeners.
Ref #22911
The text was updated successfully, but these errors were encountered: