Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(replay): Handle compression failures more robustly#6988
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -21,19 +21,12 @@ export class EventBufferProxy implements EventBuffer { | ||
| this._compression = new EventBufferCompressionWorker(worker); | ||
| this._used = this._fallback; | ||
| this._ensureWorkerIsLoadedPromise = this._ensureWorkerIsLoaded().catch(() => { | ||
| // Ignore errors here | ||
| }); | ||
| this._ensureWorkerIsLoadedPromise = this._ensureWorkerIsLoaded(); | ||
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to catch this, as we catch everything in this method now. | ||
| } | ||
| /** @inheritDoc */ | ||
| public get pendingLength(): number { | ||
| return this._used.pendingLength; | ||
| } | ||
| /** @inheritDoc */ | ||
| public get pendingEvents(): RecordingEvent[] { | ||
| return this._used.pendingEvents; | ||
| public get hasEvents(): boolean { | ||
| return this._used.hasEvents; | ||
| } | ||
| /** @inheritDoc */ | ||
| @@ -75,18 +68,28 @@ export class EventBufferProxy implements EventBuffer { | ||
| return; | ||
| } | ||
| // Compression worker is ready, we can use it | ||
| // Now we need to switch over the array buffer to the compression worker | ||
| await this._switchToCompressionWorker(); | ||
| } | ||
| /** Switch the used buffer to the compression worker. */ | ||
| private async _switchToCompressionWorker(): Promise<void> { | ||
| const { events } = this._fallback; | ||
| const addEventPromises: Promise<void>[] = []; | ||
| for (const event of this._fallback.pendingEvents) { | ||
| for (const event of events) { | ||
| addEventPromises.push(this._compression.addEvent(event)); | ||
| } | ||
| // We switch over to the compression buffer immediately - any further events will be added | ||
| // We switch over to the new buffer immediately - any further events will be added | ||
| // after the previously buffered ones | ||
| this._used = this._compression; | ||
| // Wait for original events to be re-added before resolving | ||
| await Promise.all(addEventPromises); | ||
| try { | ||
| await Promise.all(addEventPromises); | ||
| } catch (error) { | ||
| __DEBUG_BUILD__ && logger.warn('[Replay] Failed to add events when switching buffers.', error); | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pendingEvents was added to attempt to send a segment on unload (without compression), but since we have decided to pause on that, I think it's good to remove this 👍