Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
Object lost its type and functions when passed by a web worker

I am using create-react-app and the lib d3-delaunay (https://github.com/d3/d3-delaunay) to generate a voronoi diagram. It is generated in a web worker managed with https://github.com/developit/workerize-loader. When passed to the main thread the generated object loses its attributes. js logs

I cannot longer use the render fucntion I need to use so I tried to play with Object.assign and Object.create but I didn't succeed. What should I do?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

When you pass an object between threads, the structured clone algorithm is used to make a copy of the object, which doesn't include functions. From that MDN link:

Things that don't work with structured clone

  • Function objects cannot be duplicated by the structured clone algorithm; attempting to throws a DataCloneError exception.
  • Cloning DOM nodes likewise throws a DataCloneError exception.
  • Certain object properties are not preserved:
    • The lastIndex property of RegExp objects is not preserved.
    • Property descriptors, setters, getters, and similar metadata-like features are not duplicated. For example, if an object is marked readonly with a property descriptor, it will be read/write in the duplicate, since that's the default.
    • The prototype chain is not walked or duplicated.
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!