developit / developit/workerize-loader

Error when initializing Child Workers

Abierto
#99 2 comentarios 2 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
2.3k
Forks
85
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I tried initializing child web workers from a parent worker, and it seems to work well with the exception of the following error being thrown:

```
rpc-wrapper.js:20 Uncaught ReferenceError: document is not defined
at Worker. (rpc-wrapper.js:20)
```

Digging in, it seems like its part of building up the `ready` event, although document is not in scope in the context of a WebWorker.

```
let evt = document.createEvent('Event');
evt.initEvent(d.method, false, false);
evt.data = d.params;
worker.dispatchEvent(evt);
```

What is the purpose of the `ready` event? Is there a way to build the event in a WebWorker-safe manner? I've looked into `new Event`, but that's not IE compatible.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Start in rpc-wrapper.js at the ready-event code around line 20 and trace how child workers are initialized from a parent worker. Check why document is accessed in that path and how the ready event is expected to behave. Done means child workers initialize without the document error while preserving the ready event and its IE compatibility.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, webpack
Área
tooling, web-dev
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
38/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.