Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

190
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda