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

Pass through WebSocket abnormal closure code #495

Merged
merged 1 commit into from
Feb 9, 2023

Conversation

mrbbot
Copy link
Contributor

@mrbbot mrbbot commented Feb 7, 2023

Previously, the abnormal closure close code 1006 was passed directly to StandardWebSocket#close(). This is forbidden, throwing an uncatchable validation error. With this change, the WebSocket is terminate()ed instead, propagating the 1006 code correctly to the other side of the connection.

Closes #465
Ref #493

Previously, the abnormal closure close code `1006` was passed
directly to `StandardWebSocket#close()`. This is forbidden, throwing
an uncatchable validation error. With this change, the WebSocket
is `terminate()`ed instead, propagating the `1006` code correctly to
the other side of the connection.

Ref #493
@mrbbot mrbbot requested a review from penalosa February 7, 2023 17:22
@changeset-bot
Copy link

changeset-bot bot commented Feb 7, 2023

⚠️ No Changeset found

Latest commit: 703eafc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mrbbot mrbbot changed the title Pass through WebSocket abnormal closure code, Pass through WebSocket abnormal closure code Feb 8, 2023
Copy link
Contributor

@penalosa penalosa left a comment

Choose a reason for hiding this comment

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

Why the rename to _kClose?

@mrbbot
Copy link
Contributor Author

mrbbot commented Feb 9, 2023

Why the rename to _kClose?

I wanted to access this symbol in a test as regular close() rejects code 1006 as it's reserved (admittedly I probably shouldn't be relying on internal behaviour in the tests), but I don't want to expose this to users of the @miniflare/web-sockets package. Marking it as @internal will hide it from the bundled *.d.ts file, but API extractor requires all internal symbols be prefixed with an _.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] ws/lib/sender.js:162: 'First argument must be a valid error code number'
2 participants