mathe42 / vite-plugin-comlink

Use WebWorkers in Vite with comlink!
MIT License
170 stars 18 forks source link

How to Terminate Web Worker if Task is Completed. #132

Closed janaanimator closed 7 months ago

janaanimator commented 7 months ago

1) How do I terminate the Web Worker when task is completed ?

2) This code is also not helping me.

import {releaseProxy} from 'comlink'

comlink[releaseProxy]()

3) In browser I can see the Web worker running in Sources Tab.

4) In documentation also there is no proper way to Close and Terminate.

Please me give proper way to close and Terminate Web worker once Task is completed.

5) Thanks for your Plugin @mathe42 its help me reduce the development time.

6) Kindly help me ASAP.

mathe42 commented 7 months ago

If you Set myComlinkeworker = null or it gets out of scope the GC should GC the worker and terminate it.

Or you call self.close() inside the worker.

janaanimator commented 7 months ago

Thank you @mathe42 self.close(); This code Solved my Issue. Once again Thankyou.