Skip to content

Add CloseEvent #46880

Closed as not planned
Closed as not planned

Description

@regseb

What is the problem this feature will solve?

The CloseEvent class isn't defined.

What is the feature you are proposing to solve the problem?

Add the CloseEvent class in the global scope. I found it in undici.

What alternatives have you considered?

Export CloseEvent class from events.

Activity

  1. added
    eventsIssues and PRs related to EventEmitter and the events module.
    on Feb 28, 2023
  2. bnoordhuis commented on Feb 28, 2023

    @bnoordhuis
    Member

    I'm inclined to say exporting CloseEvent doesn't make sense because it's a websockets things, something node doesn't support natively.

  3. regseb commented on Feb 28, 2023

    @regseb
    ContributorAuthor

    I thought WebSockets were implemented in Node. I use mock-socket which automatically adds the WebSocket class to the global scope, but not CloseEvent.

    I agree to add CloseEvent when Node will support WebSocket. There is already an issue #19308 for adding WebSockets. And nodejs/undici#1795 already implements it, but it doesn't export CloseEvent https://github.com/nodejs/undici/pull/1795/files#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346:

        module.exports.getGlobalOrigin = getGlobalOrigin
      }
    
    + if (nodeMajor >= 18) {
    +   const { WebSocket } = require('./lib/websocket/websocket')
    +
    +   module.exports.WebSocket = WebSocket
    + }
    +
      module.exports.request = makeDispatcher(api.request)
      module.exports.stream = makeDispatcher(api.stream)
      module.exports.pipeline = makeDispatcher(api.pipeline)
  4. bnoordhuis commented on Mar 1, 2023

    @bnoordhuis
    Member

    I'll close this then. It's something we can revisit if and when node implements websockets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    eventsIssues and PRs related to EventEmitter and the events module.feature requestIssues requesting new Node.js features.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions