-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(nuxt): Stop flushing the client on every HTTP response #23312
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
Open
logaretm
wants to merge
1
commit into
develop
Choose a base branch
from
awad/nuxt-flush-client-report-per-response
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+49
−17
Open
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
dev-packages/e2e-tests/test-applications/nuxt-4/server/api/flush-regression.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,9 @@ | ||
| import { defineEventHandler } from '#imports'; | ||
| import * as Sentry from '@sentry/nuxt'; | ||
|
|
||
| export default defineEventHandler(() => { | ||
| // Seed a pending client-report outcome without sending an event, so the test can observe whether the | ||
| // SDK wrongly flushes (and ships) it per HTTP response instead of aggregating it. | ||
| Sentry.getClient()?.recordDroppedEvent('before_send', 'error'); | ||
| return { seeded: true }; | ||
| }); |
34 changes: 34 additions & 0 deletions
34
dev-packages/e2e-tests/test-applications/nuxt-4/tests/flush-regression.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,34 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import { waitForEnvelopeItem } from '@sentry-internal/test-utils'; | ||
|
|
||
| // Regression test for https://github.com/getsentry/sentry-javascript/issues/23306 | ||
| // | ||
| // The httpIntegration `responseHook` used to call `vercelWaitUntil(flushSafelyWithTimeout())`, which | ||
| // evaluates the flush eagerly regardless of platform. On a long-running server that meant `flush()` ran | ||
| // on every HTTP response, shipping each pending outcome as its own `client_report` envelope instead of | ||
| // aggregating it on the flush interval. | ||
| test('does not ship a client_report per HTTP response', async ({ request }) => { | ||
| const requestCount = 5; | ||
|
|
||
| // Resolve as soon as a second client_report is observed. A single one is tolerated because the 60s | ||
| // client-report interval may happen to flush the seeded outcomes once during the window. | ||
| let seen = 0; | ||
| const twoReportsSeen = waitForEnvelopeItem('nuxt-4', item => item[0].type === 'client_report' && ++seen >= 2) | ||
| .then(() => 'two-or-more' as const) | ||
| .catch(() => 'two-or-more' as const); | ||
|
|
||
| // Each request seeds one pending outcome (see server/api/flush-regression.ts). | ||
| for (let i = 0; i < requestCount; i++) { | ||
| await request.get('/api/flush-regression'); | ||
| } | ||
|
|
||
| // Buggy build: each response flushes -> one client_report per request, so a second arrives within ms. | ||
| // Fixed build: flushIfServerless no-ops on a long-running server, so the outcomes aggregate and at | ||
| // most the single interval flush ships within this window. | ||
| const result = await Promise.race([ | ||
| twoReportsSeen, | ||
| new Promise<'at-most-one'>(resolve => setTimeout(() => resolve('at-most-one'), 5000)), | ||
| ]); | ||
|
|
||
| expect(result).toBe('at-most-one'); | ||
| }); | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.