Repository navigation
Fix app dev exiting on non-JSON extensions WebSocket messages - #9040
Open
isaacroldan wants to merge 1 commit into
Open
isaacroldan wants to merge 1 commit into
isaacroldan wants to merge 1 commit into
Conversation
getOnMessageHandler called JSON.parse on every incoming message without a try/catch. When a client sent a text message that is not valid JSON, the SyntaxError escaped the socket's message listener as an uncaught exception and `app dev` exited. Catch the SyntaxError, log it with outputDebug, and ignore the message. Add a regression test in handlers.test.ts. 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 sends a text message that is not valid JSON.getOnMessageHandlerinpackages/app/src/cli/services/dev/extension/websocket/handlers.tscallsJSON.parseon every message without atry/catch. TheSyntaxErrorescapes the socket'smessagelistener as an uncaught exception, and the process stops.WHAT is this pull request doing?
SyntaxErrorfromJSON.parse, logs it withoutputDebug, and ignores the message. Other errors still propagate.handlers.test.tsfor a message that is not JSON.@shopify/app.Before, a client that sends
not jsonstops the dev session:After, the session continues. With
--verbose, the CLI prints:How to manually test your changes?
shopify app dev --verbosein an app with a UI extension./extensions, for examplenpx wscat -c ws://localhost:<port>/extensions.not json.app devkeeps running and prints the debug line above.{"event":"dispatch","data":{"type":"focus","extensions":[]}}, and confirm that the connected clients receive it.Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add