Skip to content

throw a new wrapped error instead of default one from segment#10118

Merged
Gudahtt merged 2 commits intodevelopfrom
fix-firefox-freezes
Dec 23, 2020
Merged

throw a new wrapped error instead of default one from segment#10118
Gudahtt merged 2 commits intodevelopfrom
fix-firefox-freezes

Conversation

@brad-decker
Copy link
Copy Markdown
Contributor

@brad-decker brad-decker commented Dec 22, 2020

@Gudahtt was able to reproduce the firefox freezing using tracking protection in Firefox, or by blocking segment in chrome. The problem, as he discovered, seems to be in something that segment was doing with its error objects. I just changed the metametrics implementation to reject with a new error, using the original error's message and stack trace

Copy link
Copy Markdown
Member

@rekmarks rekmarks left a comment

Choose a reason for hiding this comment

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

Let's add a comment explaining why we're doing this, and the horrors we invite if we don't.

Also, should we try to preserve any other properties? Could we preserve the stack here? 🤔

@brad-decker
Copy link
Copy Markdown
Contributor Author

Preserved the stack, which i feared would also blow it up, but its good. Added an explanatory comment and named the new error 'safeError'

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [4218e30]
Page Load Metrics (520 ± 44 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint31644994
domContentLoaded3346415199144
load3356435209144
domInteractive3346405199144

@Gudahtt Gudahtt marked this pull request as ready for review December 23, 2020 03:49
@Gudahtt Gudahtt requested a review from a team as a code owner December 23, 2020 03:49
@Gudahtt Gudahtt dismissed rekmarks’s stale review December 23, 2020 03:49

Changes requested have been made

Copy link
Copy Markdown
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM! I have tested this with the same repro I used to see v8.1.9 freeze, and this does seem to resolve the problem.

I tested this with a build made using the command SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='aaa' SEGMENT_LEGACY_WRITE_KEY='aaa' yarn dist. On Firefox, I tested with Enhanced Tracking Protection set to strict mode, which results in segment.io being blocked. On Chrome, I just blocked segment.io in the dev console for the background process. On both browsers, the UI would freeze during onboarding before this commit but not after.

I think there is still some room for improvement here - we can detect the specific errors causing this problem (the axios errors) because they have the property isAxiosError, and we can pull more useful information from them like the HTTP status code. But that can wait for another time.

@Gudahtt Gudahtt merged commit 64adcae into develop Dec 23, 2020
@Gudahtt Gudahtt deleted the fix-firefox-freezes branch December 23, 2020 03:54
@github-actions github-actions bot locked and limited conversation to collaborators Dec 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants