-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.
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 👍