fix(wasm): shutdown async runtime and thread workers after finishing#9895
Conversation
✅ Deploy Preview for rspack canceled.Built without sensitive environment variables
|
|
Would you please elaborate on "I find the main thread in nodejs doesn't exit if nodejs worker get stuck."? Is this problem exist when nodejs workers encounter some error or exist on every executions? |
CodSpeed Performance ReportMerging #9895 will not alter performanceComparing Summary
|
Here is an example. When you run // main.js
const { Worker } = require('worker_threads');
const worker = new Worker('./worker.js')
console.log("main end")
// worker.js
console.log("worker start")
while (true) {}
console.log("worker end")Now let me clarify the problems with
|
That's weird. I haven't really dug into the implementation in WASI node. But I thought rayon tasks would be sent to
Is it possible to |
You could be right! Actually I know this from https://github.com/rayon-rs/rayon?tab=readme-ov-file#usage-with-webassembly, but I think it's very valuable to optimize in the future.
Thanks! I didn't know this api before. I quickly tried but didn't solve the problem. I will do more research about it. |
394d2ee to
d5d12b9
Compare
|
It seems that |
Summary
The reason I make this pr separately is that I'm not sure if my solution is best. So discussions are welcome.
Rspack wasi will get stuck after finishing, because:
Temporarily I stop napi generating js glue code and export the function to shutdown workers. And I'm not sure the replace where I put shutdown code is correct.
Checklist