feat(replay): Handle worker loading errors #6827
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 wrappingEventBufferProxy
.This proxy initializes both an
EventBufferArray
as well as anEventBufferCompressionWorker
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.