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

Project crashed after Worker.terminate() #41107

Open
KunalBurangi opened this issue Dec 7, 2021 · 2 comments
Open

Project crashed after Worker.terminate() #41107

KunalBurangi opened this issue Dec 7, 2021 · 2 comments
Labels
windows Issues and PRs related to the Windows platform. worker Issues and PRs related to Worker support.

Comments

@KunalBurangi
Copy link

Version

14.6

Platform

Windows 10

Subsystem

No response

What steps will reproduce the bug?

Not sure

How often does it reproduce? Is there a required condition?

I am working with the worker threads and it is working fine . i am able to execute stuff in worker thread but the problem is the worker thread is not getting exit on its own . so i am using process.exit(0) or worker.terminate()
and it get exits also.
but after that if i hit the api again then my project crashes with
Process exited with code 3221225477

what is the issue

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

@Mesteery Mesteery added the worker Issues and PRs related to Worker support. label Dec 7, 2021
@e3dio
Copy link

e3dio commented Dec 16, 2021

I also see this (node 17, win11), looks related to native addons (C++), only occurs on Windows no issue on Linux, specifically when the last remaining Worker Thread that has loaded the native addon exits it will crash the process with error code 3221225477. I don't know if it's because the addon did not clean up resources correctly or if is some issue with Node https://nodejs.org/api/addons.html#worker-support. The crash happens after process.on('exit') event fires on the worker, but before worker.on('exit') event fires on main thread, and only occurs after the last remaining worker (can be 1 or more workers) that has loaded the addon exits.

@Mesteery Mesteery added the windows Issues and PRs related to the Windows platform. label Dec 16, 2021
@e3dio
Copy link

e3dio commented Dec 16, 2021

The example code below works as is, worker thread (from main) exited and main thread exited get logged, but if you uncomment addon require('uWebSockets.js') it will crash the process with code 3221225477 after logging worker thread (inside) exited and the other logs don't get called. Works fine on Linux

const {Worker,isMainThread}=require('worker_threads')
if(isMainThread){
	new Worker(__filename).on('exit',code=>console.log('worker thread (from main) exited',code))
	process.on('exit',()=>console.log('main thread exited'))
}else{
	//require('uWebSockets.js')
	process.on('exit',()=>console.log('worker thread (inside) exited'))
	setTimeout(()=>process.exit(0),1000)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
windows Issues and PRs related to the Windows platform. worker Issues and PRs related to Worker support.
Projects
None yet
Development

No branches or pull requests

3 participants