Repository navigation
Fix app dev crash on malformed /extensions WebSocket frames - #9039
Open
isaacroldan wants to merge 1 commit into
Open
isaacroldan wants to merge 1 commit into
isaacroldan wants to merge 1 commit into
Conversation
getConnectionDoneHandler registered a message listener on each socket but no error listener. When a client breaks the WebSocket protocol, for example with a frame larger than maxPayload, ws emits 'error' on the socket. With no listener, Node throws it as an unhandled error and `app dev` exits. Log the error with outputDebug. ws already closes the failing connection (1009 for an oversized frame), so the server and the other clients keep working. Co-authored-by: isaac.roldan <isaac.roldan@shopify.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
shopify app devexits when a client of the/extensionsWebSocket breaks the WebSocket protocol, for example with a frame larger thanmaxPayload. The local proxy stops with it.getConnectionDoneHandlerregisters amessagelistener on each socket, but noerrorlistener. On a protocol error,wsemitserroron the socket. With no listener, Node throws it as an unhandled error (RangeError: Max payload size exceeded) and the process exits.WHAT is this pull request doing?
errorlistener to each/extensionssocket. It logs the error withoutputDebug.wsalready closes the failing connection (code1009for an oversized frame), so the server and the other clients keep working.handlers.test.ts:errorevent on a connected socket does not throw and is logged.1009. A new client can then connect and send a dispatch, and an existing client receives it.@shopify/app.How to manually test your changes?
shopify app dev --verbosein an app with a UI extension.ws://localhost:<port>/extensionswith a WebSocket client and send a frame larger than 100 MiB. Withwsin Node:app devexits withRangeError: Max payload size exceeded. After this change, the client printsclosed 1009,app devkeeps running, and the verbose output showsWebsocket connection error: Max payload size exceeded.Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add