Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing ErrorEvent #47587

Open
jimmywarting opened this issue Apr 17, 2023 · 8 comments
Open

Missing ErrorEvent #47587

jimmywarting opened this issue Apr 17, 2023 · 8 comments
Labels
feature request Issues that request new features to be added to Node.js.

Comments

@jimmywarting
Copy link

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

@jimmywarting jimmywarting added the feature request Issues that request new features to be added to Node.js. label Apr 17, 2023
@bnoordhuis
Copy link
Member

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.

@jimmywarting
Copy link
Author

jimmywarting commented Apr 18, 2023

As a effort into implementing spec'ed web worker (#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.

@jimmywarting
Copy link
Author

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

@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot added the stale label Oct 16, 2023
@regseb
Copy link
Contributor

regseb commented Oct 19, 2023

  • CloseEvent: For when a WebbSocket closes.
  • ErrorEvent: For when WebSocket fails and you also get this on globalThis.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 #50275 to add CloseEvent in Node.js.

@github-actions github-actions bot removed the stale label Oct 20, 2023
Copy link
Contributor

There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the never-stale Mark issue so that it is never considered 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.

@github-actions github-actions bot added the stale label Apr 17, 2024
@KhafraDev
Copy link
Member

WebSocket may use ErrorEvents, see the spec: https://html.spec.whatwg.org/multipage/indices.html#event-error

@regseb
Copy link
Contributor

regseb commented Apr 26, 2024

@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:

  • fire an event named error at the WebSocket object.
  • Fire an event named close at the WebSocket object, using CloseEvent,

web-platform-tests only tests Event for error:

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));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js.
Projects
Status: Pending Triage
Development

No branches or pull requests

4 participants