I am trying to use CustomEvent for communicating between the main thread and the worker thread(s).
Worker.dispatchEvent(event) raises an error: TypeError: Cannot set property currentTarget of #<Event> which has only a getter
Reproduction
In the worker code,
const e = new CustomEvent("my-custom-event");
globalThis.dispatchEvent(e);
The issue is related to Event.target and Event.currentTarget being read-only values. Worker.dispatchEvent tries to redefine them after initialiation, hence causing this error.
System
web-worker v1.2.0
node 20.13.1
Why am I not using v1.3.0 ?
Issue with ES support in v1.3.0 - see #44
Description
I am trying to use CustomEvent for communicating between the main thread and the worker thread(s). Worker.dispatchEvent(event) raises an error:
TypeError: Cannot set property currentTarget of #<Event> which has only a getter
Reproduction
In the worker code,
The issue is related to Event.target and Event.currentTarget being read-only values. Worker.dispatchEvent tries to redefine them after initialiation, hence causing this error.
System
web-worker
v1.2.0node
20.13.1