Open jimmywarting opened 1 year ago
Node doesn't emit ErrorEvents itself so it's questionable if it makes sense to add it.
But... without working code it won't happen in the first place. Go ahead and open a pull request and see how it's received.
As a effort into implementing spec'ed web worker (https://github.com/nodejs/node/issues/43583) (which is highly desirable and upvoted) then the worker.onerror
would have to emit a ErrorEvent
.
I notice this when i tried to build a more spec comp. web worker.
I have notice other events that Deno also has... here is a list of them: https://github.com/jimmywarting/missing-dom-events#compatibility-table
CloseEvent
: For when a WebbSocket closes.ErrorEvent
: For when WebSocket fails and you also get this on globalThis.onerror
anyway undici have both of this event builtin, maybe it could just be a mater of just exposing those on the global scope?
There is also a desire to make globalThis
inherit EventTarget
in some open issue here too. so it can dispatch/emit postMessages, ErrorEvents
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
CloseEvent
: For when a WebbSocket closes.ErrorEvent
: For when WebSocket fails and you also get this onglobalThis.onerror
ErrorEvent
isn't used by WebSocket
. The error
event of WebSocket
returns a generic Event
. Maybe only web workers use ErrorEvent
.
Now that WebSocket
is in Node.js v21 (behind the --experimental-websocket
flag), I've opened an issue https://github.com/nodejs/node/issues/50275 to add CloseEvent
in Node.js.
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the https://github.com/nodejs/node/labels/never-stale label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document.
WebSocket may use ErrorEvents, see the spec: https://html.spec.whatwg.org/multipage/indices.html#event-error
@KhafraDev The https://html.spec.whatwg.org/multipage/indices.html#event-error page describes the general HTML specification. The word WebSocket
doesn't appear. For the error
event, it indicates that the type may be Event
or ErrorEvent
.
The MDN page WebSocket: error event indicates only A generic Event
.
The WebSocket specification doesn't mention ErrorEvent
. For events, it doesn't specify the type of error
events, whereas for the close
event, it's a CloseEvent
:
error
at the WebSocket
object.close
at the WebSocket
object, using CloseEvent
,web-platform-tests only tests Event
for error
:
assert_true(e instanceof Event)
assert_equals(e.toString(), '[object Event]', "error e.toString()")
assert_true(e instanceof Event)
.If I run the following code in Firefox or Chromium, e
is an Event
variable.
new WebSocket("ws://localhost:666").addEventListener("error", (e) => console.log(e, e.constructor.name));
What is the problem this feature will solve?
Where trying to construct a new
ErrorEvent
... but it was defined.What is the feature you are proposing to solve the problem?
A few web features can dispatch a ErrorEvent like web workers...
What alternatives have you considered?
No response