-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix(replay): Ensure we do not try to flush when we force stop replay #8783
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bc1b883
fix(replay): Ensure we do not try to flush when we force stop replay
mydea afa9602
add debugging...
mydea 0884499
moare debugging
mydea 703eb08
even more debugging
mydea 278b12d
again the debugging...
mydea 26cb98b
MORE logging...
mydea 81ed9bd
fix it??
mydea 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
10 changes: 10 additions & 0 deletions
10
packages/browser-integration-tests/suites/replay/eventBufferError/template.html
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
</head> | ||
<body> | ||
<button onclick="console.log('Test log')" id="button1">Click me</button> | ||
<button onclick="console.log('Test log 2')" id="button2">Click me</button> | ||
</body> | ||
</html> |
89 changes: 89 additions & 0 deletions
89
packages/browser-integration-tests/suites/replay/eventBufferError/test.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { envelopeRequestParser } from '../../../utils/helpers'; | ||
import { | ||
getDecompressedRecordingEvents, | ||
getReplaySnapshot, | ||
isReplayEvent, | ||
REPLAY_DEFAULT_FLUSH_MAX_DELAY, | ||
shouldSkipReplayTest, | ||
waitForReplayRequest, | ||
} from '../../../utils/replayHelpers'; | ||
|
||
sentryTest( | ||
'should stop recording when running into eventBuffer error', | ||
async ({ getLocalTestPath, page, forceFlushReplay }) => { | ||
if (shouldSkipReplayTest()) { | ||
sentryTest.skip(); | ||
} | ||
|
||
await page.route('https://dsn.ingest.sentry.io/**/*', route => { | ||
return route.fulfill({ | ||
status: 200, | ||
}); | ||
}); | ||
|
||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
await page.goto(url); | ||
|
||
await waitForReplayRequest(page); | ||
const replay = await getReplaySnapshot(page); | ||
expect(replay._isEnabled).toBe(true); | ||
|
||
await forceFlushReplay(); | ||
|
||
let called = 0; | ||
|
||
await page.route('https://dsn.ingest.sentry.io/**/*', route => { | ||
const event = envelopeRequestParser(route.request()); | ||
|
||
// We only want to count replays here | ||
if (event && isReplayEvent(event)) { | ||
const events = getDecompressedRecordingEvents(route.request()); | ||
// this makes sure we ignore e.g. mouse move events which can otherwise lead to flakes | ||
if (events.length > 0) { | ||
called++; | ||
} | ||
} | ||
|
||
return route.fulfill({ | ||
status: 200, | ||
}); | ||
}); | ||
|
||
called = 0; | ||
|
||
/** | ||
* We test the following here: | ||
* 1. First click should add an event (so the eventbuffer is not empty) | ||
* 2. Second click should throw an error in eventBuffer (which should lead to stopping the replay) | ||
* 3. Nothing should be sent to API, as we stop the replay due to the eventBuffer error. | ||
*/ | ||
await page.evaluate(` | ||
window._count = 0; | ||
window._addEvent = window.Replay._replay.eventBuffer.addEvent.bind(window.Replay._replay.eventBuffer); | ||
window.Replay._replay.eventBuffer.addEvent = (...args) => { | ||
window._count++; | ||
if (window._count === 2) { | ||
throw new Error('provoked error'); | ||
} | ||
window._addEvent(...args); | ||
}; | ||
`); | ||
|
||
void page.click('#button1'); | ||
void page.click('#button2'); | ||
|
||
// Should immediately skip retrying and just cancel, no backoff | ||
// This waitForTimeout call should be okay, as we're not checking for any | ||
// further network requests afterwards. | ||
await page.waitForTimeout(REPLAY_DEFAULT_FLUSH_MAX_DELAY + 100); | ||
|
||
expect(called).toBe(0); | ||
|
||
const replay2 = await getReplaySnapshot(page); | ||
|
||
expect(replay2._isEnabled).toBe(false); | ||
}, | ||
); |
This file contains 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 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 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 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 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 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 |
---|---|---|
|
@@ -472,10 +472,9 @@ describe('Integration | flush', () => { | |
const TEST_EVENT = { data: {}, timestamp: BASE_TIMESTAMP + 100, type: 2 }; | ||
mockRecord._emitter(TEST_EVENT); | ||
|
||
await advanceTimers(DEFAULT_FLUSH_MIN_DELAY); | ||
await advanceTimers(160_000); | ||
|
||
expect(mockFlush).toHaveBeenCalledTimes(2); | ||
expect(mockFlush).toHaveBeenCalledTimes(1); | ||
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. This also shows the incorrect behavior, it was flushing twice before even though it shouldn't have. |
||
expect(mockSendReplay).toHaveBeenCalledTimes(0); | ||
expect(replay.isEnabled()).toBe(false); | ||
|
||
|
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.
For this case we still want to flush I guess? The integration test failed for this, and I guess it is OK to do a final flush here to have details on why this was stopped - we do not add the large mutations anyhow yet, so should be fine?