stockfish.wasm icon indicating copy to clipboard operation
stockfish.wasm copied to clipboard

How to kill process created by Stockfish()?

Open pronode opened this issue 2 years ago • 2 comments

When you execute Stockfish() it creates an instance of something (engine I guess?) that sits in memory until the main process is killed. Is it possible to kill that thing someway without killing main thread?

I'm running stockfish.wasm on Node.JS server.

pronode avatar Jan 11 '23 14:01 pronode

Unfortunately I don't know a clean way. It's possible to call sf.terminate() given sf is an instance, but it does not work reliably:

https://github.com/lichess-org/lila/blob/5d26cf97458fa3772d21dee65a61d217058e617b/ui/ceval/src/worker.ts#L204-L206

niklasf avatar Jan 11 '23 17:01 niklasf

It's possible to call sf.terminate() given sf is an instance, but it does not work reliably

Yes, it does nothing. The workaround is to encapsulate everything in separate worker process and kill that worker when it's needed.

pronode avatar Jan 26 '23 09:01 pronode