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

fix: json parse unhandled #5404

Merged
merged 1 commit into from
Sep 30, 2024
Merged

fix: json parse unhandled #5404

merged 1 commit into from
Sep 30, 2024

Conversation

ganchoradkov
Copy link
Member

Description

Fixed unhandled exception while trying to json.parse incoming window messages. Now we try to parse only strings and additional try/catch was added

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Draft PR (breaking/non-breaking change which needs more work for having a proper functionality [Mark this PR as ready to review only when completely ready])
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How has this been tested?

dogfooding

Checklist

  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Additional Information (Optional)

Please include any additional information that may be useful for the reviewer.

Copy link
Contributor

@Cali93 Cali93 left a comment

Choose a reason for hiding this comment

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

Thanks for the super quick fix 🏎️

resolve(data.attestation === null ? "" : data.attestation);
if (typeof event.data !== "string") return;
try {
const data = JSON.parse(event.data);
Copy link
Contributor

@Cali93 Cali93 Sep 30, 2024

Choose a reason for hiding this comment

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

This will throw if the data is a string but not parsable so alternatively you could also have a try catch just around the JSON.parse()
And log event.data with something like, invalid event payload -> even.data

@ganchoradkov ganchoradkov merged commit 744e71f into v2.0 Sep 30, 2024
13 checks passed
@ganchoradkov ganchoradkov deleted the fix/json-parse-err branch September 30, 2024 11:47
@ganchoradkov ganchoradkov mentioned this pull request Oct 1, 2024
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants