wilk / microjob

A tiny wrapper for turning Node.js worker threads into easy-to-use routines for heavy CPU loads.
https://wilk.github.io/microjob/
MIT License
2.02k stars 47 forks source link

function could not be cloned #64

Open mikejernil opened 4 years ago

mikejernil commented 4 years ago

I'm using a function inside my job since it is from a library i use for compression and it is the CPU intensive task i need to allocate to the worker thread. this is returning an Error for me saying ' The function{ } cannot be cloned '. What does this mean & how do i solve this?

If this is not the proper place to ask this and you'd prefer i ask this on stack overflow, i'll bring this down.

dgellow commented 5 months ago

Unfortunately that's a limitation of the cloning algorithm used when passing data to worker threads. See https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm. That's not something that can be solved without changes to javascript engines.