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
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
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 |
|---|---|---|
| @@ -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> |
| 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); | ||
| }); |
| 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(); | ||
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. 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'); | ||
| 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<{ | ||
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. 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 | ||
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!