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

What is the correct way to terminate a worker via Thread and BlobWorker? #491

Open
alexpreynolds opened this issue Jun 28, 2024 · 0 comments

Comments

@alexpreynolds
Copy link

I instantiate a worker:

import { spawn, Thread, BlobWorker } from 'threads';
import MyWorkerWeb from 'raw-loader!../dist/worker.js';

let worker = spawn(BlobWorker.fromText(MyWorkerWeb));

//
// do stuff with worker
// ...

When I am done with the worker, I would like to terminate it to remove it from memory and from the list of dedicated workers in the Task Manager:

Thread.terminate(worker);

This line of code returns the following error:

thread[symbols_1.$terminate] is not a function
TypeError: thread[symbols_1.$terminate] is not a function
    at Object.terminate (http://localhost:3000/static/js/src_App_js-data_image_svg_xml_3csvg_xmlns_27http_www_w3_org_2000_svg_27_viewBox_27-4_-4_8_8_2-577bb7.chunk.js:28287:48)

Is there a correct way to terminate this worker, which does not require reloading the document (web page)?

Thanks for your advice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant