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

lib: expose global CloseEvent #53355

Merged
merged 1 commit into from
Jun 7, 2024

Conversation

KhafraDev
Copy link
Member

This PR adds CloseEvent as a global, which can be disabled via the --no-experimental-websocket flag.

const ws = new WebSocket('https://echo.websocket.org/')

ws.addEventListener('open', () => ws.close())

ws.addEventListener('close', (event) => {
  assert(event instanceof CloseEvent)
  console.log('closed!')
})

Fixes: #50275

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Jun 5, 2024

Review requested:

  • @nodejs/startup
  • @nodejs/web-standards

@KhafraDev KhafraDev added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jun 5, 2024
@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. process Issues and PRs related to the process subsystem. labels Jun 5, 2024
This PR adds `CloseEvent` as a global, which can be disabled
via the --no-experimental-websocket flag.

```js
const ws = new WebSocket('...')

ws.addEventListener('close', (event) => {
  assert(event instanceof CloseEvent)
})

```

Fixes: nodejs#50275
Copy link
Member

@benjamingr benjamingr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nodejs/tsc @nodejs/web-standards since this adds a global, pinging for visibility.

LGTM thanks for this 🙏

@KhafraDev KhafraDev added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jun 5, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 5, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

Copy link
Contributor

@ShogunPanda ShogunPanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina added the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 6, 2024
@mcollina mcollina added commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. needs-ci PRs that need a full CI run. labels Jun 7, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 7, 2024
@nodejs-github-bot nodejs-github-bot merged commit 6ed93b4 into nodejs:main Jun 7, 2024
62 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 6ed93b4

@KhafraDev KhafraDev deleted the global-closeevent branch June 7, 2024 18:00
EliphazBouye pushed a commit to EliphazBouye/node that referenced this pull request Jun 20, 2024
This PR adds `CloseEvent` as a global, which can be disabled
via the --no-experimental-websocket flag.

```js
const ws = new WebSocket('...')

ws.addEventListener('close', (event) => {
  assert(event instanceof CloseEvent)
})

```

Fixes: nodejs#50275
PR-URL: nodejs#53355
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
bmeck pushed a commit to bmeck/node that referenced this pull request Jun 22, 2024
This PR adds `CloseEvent` as a global, which can be disabled
via the --no-experimental-websocket flag.

```js
const ws = new WebSocket('...')

ws.addEventListener('close', (event) => {
  assert(event instanceof CloseEvent)
})

```

Fixes: nodejs#50275
PR-URL: nodejs#53355
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. lib / src Issues and PRs related to general changes in the lib or src directory. process Issues and PRs related to the process subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[WebSocket] Add CloseEvent
6 participants