Skip to content

feat(replay): Handle worker loading errors #6827

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

Merged
merged 4 commits into from
Jan 19, 2023
Merged

Conversation

mydea
Copy link
Member

@mydea mydea commented Jan 17, 2023

This PR updates the replay buffer to handle errors in the worker.

While with the current worker implementation this is just a rather safe approach, it becomes necessary when we want to load a worker from an external (e.g. CDN) url. In that case, if loading the worker fails, we need to handle this in an async way.

With this PR, when compression is enabled, we don't use the EventBufferCompressionWorker but a wrapping EventBufferProxy.

This proxy initializes both an EventBufferArray as well as an EventBufferCompressionWorker under the hood. Initially, any events & flushes are handled by the simple buffer. Once we know the compression worker has successfully loaded, we switch any pending events over and start using the worker buffer. This way, no event should ever be lost, and even in-flight flushes should all work as expected.

@mydea mydea added the Package: replay Issues related to the Sentry Replay SDK label Jan 17, 2023
@mydea mydea requested review from billyvg and Lms24 January 17, 2023 16:38
@mydea mydea self-assigned this Jan 17, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jan 17, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.82 KB (-0.01% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 61.47 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.5 KB (+0.01% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 54.77 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 20.21 KB (0%)
@sentry/browser - Webpack (minified) 66.17 KB (0%)
@sentry/react - Webpack (gzipped + minified) 20.24 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.48 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.74 KB (0%)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.03 KB (+0.02% 🔺)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 43.25 KB (-0.52% 🔽)
@sentry/replay - Webpack (gzipped + minified) 38.03 KB (-0.49% 🔽)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 60.52 KB (-0.35% 🔽)

@mydea mydea force-pushed the fn/replay-buffer-worker branch from 7bd60a8 to 637f194 Compare January 18, 2023 11:51
@mydea mydea force-pushed the fn/replay-buffer-worker branch from a6858e6 to 7895218 Compare January 18, 2023 15:32
@mydea mydea force-pushed the fn/replay-buffer-worker branch from 59b1a12 to 7663718 Compare January 18, 2023 15:56
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

I think this is a good change, considering the direction we want to move towards with the worker. For the long term, we might be able to replace the worker and proxy classes with a functional approach which might help bundle size. But I think this something that rather belongs to #6459. So let's tackle that some time in the future

@mydea mydea merged commit b83e7e1 into master Jan 19, 2023
@mydea mydea deleted the fn/replay-buffer-worker branch January 19, 2023 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: replay Issues related to the Sentry Replay SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants