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

wrap websocket messages json parsing in a try/catch #66

Merged
merged 2 commits into from
Oct 1, 2024

Conversation

patrickdbakke
Copy link

Summary

Fixes zen crashing when you repeatedly / rapidly save the same file.

Changes

Wrap json.parse() in a try catch when receiving websocket messages.

Underlying error:

ConsoleMessage {}
- 00ab756aeb8e0ba99e9f
undefined:1
- 00ab756aeb8e0ba99e9f
 ^

SyntaxError: Unexpected token   in JSON at position 1
    at JSON.parse (<anonymous>)
    at register (/Users/patrickbakke/www/desktop/node_modules/@superhuman/zen/build/cli.js:3097:30)
    at ChromeTab.onMessageAdded (/Users/patrickbakke/www/desktop/node_modules/@superhuman/zen/build/cli.js:3104:9)
    at /Users/patrickbakke/www/desktop/node_modules/@superhuman/zen/build/cli.js:2976:16
    at /Users/patrickbakke/www/desktop/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:68
    at Array.map (<anonymous>)
    at /Users/patrickbakke/www/desktop/node_modules/@superhuman/zen/node_modules/sugar/enumerable/internal/wrapNativeArrayMethod.js:12:21
    at Array.staticFn.instance (/Users/patrickbakke/www/desktop/node_modules/@superhuman/zen/node_modules/sugar/common/internal/fixArgumentLength.js:10:12)
...

Copy link

@zindlerb zindlerb left a comment

Choose a reason for hiding this comment

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

Lgtm!

@patrickdbakke patrickdbakke merged commit bcdb13e into master Oct 1, 2024
@patrickdbakke patrickdbakke deleted the fix-reload-crashes branch October 1, 2024 16:01
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