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

[Web] Service Worker: Conditionally parse as JSON #1278

merged 1 commit into from Nov 28, 2019


Copy link

sstur commented Nov 28, 2019

It's not safe to assume that is a string, and it's certainly not safe to assume it's valid JSON (for example, I noticed this when implementing Google Signin using Firebase; see screenshots below).

This PR makes it so that we check that it is a string and wrap the JSON.parse in a try/catch in case it's not JSON at all, but just some arbitrary string message sent by a library on the page.

Screenshots from some example exceptions caused by this issue:
Screen Shot 2019-11-27 at 22 30 05
Screen Shot 2019-11-27 at 22 29 53

@EvanBacon EvanBacon self-requested a review Nov 28, 2019
@EvanBacon EvanBacon assigned EvanBacon and unassigned EvanBacon Nov 28, 2019
Copy link

EvanBacon left a comment


@EvanBacon EvanBacon merged commit f2ff9c1 into expo:master Nov 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.