-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(replay): Stop without retry when receiving bad API response #6773
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
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
9 changes: 9 additions & 0 deletions
9
packages/integration-tests/suites/replay/errorResponse/template.html
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
</head> | ||
<body> | ||
<button onclick="console.log('Test log')">Click me</button> | ||
</body> | ||
</html> |
37 changes: 37 additions & 0 deletions
37
packages/integration-tests/suites/replay/errorResponse/test.ts
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { getReplaySnapshot } from '../../../utils/helpers'; | ||
|
||
sentryTest('errorResponse', async ({ getLocalTestPath, page }) => { | ||
// Currently bundle tests are not supported for replay | ||
if (process.env.PW_BUNDLE && process.env.PW_BUNDLE.startsWith('bundle_')) { | ||
sentryTest.skip(); | ||
} | ||
|
||
let called = 0; | ||
|
||
await page.route('https://dsn.ingest.sentry.io/**/*', route => { | ||
called++; | ||
|
||
return route.fulfill({ | ||
status: 400, | ||
}); | ||
}); | ||
|
||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
await page.goto(url); | ||
|
||
await page.click('button'); | ||
await page.waitForTimeout(300); | ||
|
||
expect(called).toBe(1); | ||
|
||
// Should immediately skip retrying and just cancel, no backoff | ||
await page.waitForTimeout(5001); | ||
|
||
expect(called).toBe(1); | ||
const replay = await getReplaySnapshot(page); | ||
|
||
expect(replay['_isEnabled']).toBe(false); | ||
}); |
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 |
---|---|---|
|
@@ -234,6 +234,7 @@ export class ReplayContainer implements ReplayContainerInterface { | |
this._stopRecording?.(); | ||
this.eventBuffer?.destroy(); | ||
this.eventBuffer = null; | ||
this._debouncedFlush.cancel(); | ||
} catch (err) { | ||
this._handleException(err); | ||
} | ||
|
@@ -907,7 +908,7 @@ export class ReplayContainer implements ReplayContainerInterface { | |
if (rateLimitDuration > 0) { | ||
__DEBUG_BUILD__ && logger.warn('[Replay]', `Rate limit hit, pausing replay for ${rateLimitDuration}ms`); | ||
this.pause(); | ||
this._debouncedFlush && this._debouncedFlush.cancel(); | ||
this._debouncedFlush.cancel(); | ||
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 is set in the constructor, so no need to check for existence here. |
||
|
||
setTimeout(() => { | ||
__DEBUG_BUILD__ && logger.info('[Replay]', 'Resuming replay after rate limit'); | ||
|
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ import type { DomHandler } from './../types'; | |
import type { MockSdkParams } from './mockSdk'; | ||
import { mockSdk } from './mockSdk'; | ||
|
||
export async function resetSdkMock({ replayOptions, sentryOptions }: MockSdkParams): Promise<{ | ||
export async function resetSdkMock({ replayOptions, sentryOptions, autoStart }: MockSdkParams): Promise<{ | ||
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. Just noticed that this was not actually passed through. |
||
domHandler: DomHandler; | ||
mockRecord: RecordMock; | ||
replay: ReplayContainer; | ||
|
@@ -30,6 +30,7 @@ export async function resetSdkMock({ replayOptions, sentryOptions }: MockSdkPara | |
const { replay } = await mockSdk({ | ||
replayOptions, | ||
sentryOptions, | ||
autoStart, | ||
}); | ||
|
||
// XXX: This is needed to ensure `domHandler` is set | ||
|
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.
Just a small thing I noticed while debugging tests.
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.
good catch!