Skip to content

Tidy the error-type map and WebSocket close-reason limit#209

Merged
ndisidore merged 2 commits into
cloudflare:mainfrom
ndisidore:cleanup/error-and-transport-fixes
Jul 9, 2026
Merged

Tidy the error-type map and WebSocket close-reason limit#209
ndisidore merged 2 commits into
cloudflare:mainfrom
ndisidore:cleanup/error-and-transport-fixes

Conversation

@ndisidore

Copy link
Copy Markdown
Collaborator
  • serialize.ts: use a null-prototype object literal for ERROR_TYPES instead of Object.assign(Object.create(null), ...).
  • websocket.ts: derive the close-reason cap from the RFC 6455 Close-frame size (125 - 2) rather than a bare 123, and shorten the comment.
  • test: split a multi-byte character exactly at the limit so the streaming truncation path is actually exercised (the previous input landed on a character boundary).

No behavior change.

@changeset-bot

changeset-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d3fc75d

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/capnweb@209

commit: d3fc75d

Comment thread src/rpc.ts
Comment thread src/websocket.ts Outdated

@dimitropoulos dimitropoulos left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

some small improvements suggested, but not super blocking

ndisidore added 2 commits July 9, 2026 12:24
- serialize.ts: use a null-prototype object literal for ERROR_TYPES instead of
  Object.assign(Object.create(null), ...).
- websocket.ts: derive the close-reason cap from the RFC 6455 Close-frame size
  (125 - 2) rather than a bare 123, and shorten the comment.
- test: split a multi-byte character exactly at the limit so the streaming
  truncation path is actually exercised (the previous input landed on a
  character boundary).

No behavior change.
The guard in ImportTableEntry.resolve() defended a state the protocol can't
reach: after a normal resolve the import entry is deleted (sendRelease ->
delete this.imports[id]), so a duplicate "resolve" message lands on the
"import not found" path and never calls resolve() a second time. Its test also
passed with the guard removed. Remove both, and drop the changeset since this
is a cleanup with no behavior change.
@ndisidore ndisidore force-pushed the cleanup/error-and-transport-fixes branch from 4ced72a to d3fc75d Compare July 9, 2026 17:25
@ndisidore ndisidore merged commit ee7ca6f into cloudflare:main Jul 9, 2026
5 checks passed
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.

2 participants