Skip to content

test(nextjs): Switch DEBUG_BUILD with a getter instead of re-importing the SDK - #25279

Merged
JPeer264 merged 1 commit into
jp/aws-e2e-loopback-hostfrom
jp/flaky-nextjs-debug-build-mock
Oct 14, 2026
Merged

JPeer264 merged 1 commit into
jp/aws-e2e-loopback-hostfrom
jp/flaky-nextjs-debug-build-mock

Conversation

@JPeer264

Copy link
Copy Markdown
Member

conflictingDebugOptions.test.ts now mocks DEBUG_BUILD one time, with a getter over a vi.hoisted value, and it imports the client, server and edge entry points one time. Before, each test called vi.doMock and vi.resetModules and imported all three entry points again, and beforeAll "pre-warmed" them one more time.

Why

Under CI load, evaluating the three module graphs again took longer than the 10 s hook timeout. Now the two tests take a few milliseconds (25 ms and 6 ms locally, 1.68 s before). The "vi.unmock is not at the top level" warning is also gone.

Failed on CI: https://github.com/getsentry/sentry-javascript/actions/runs/38034725173/job/114166137692

@JPeer264
JPeer264 added this pull request to stack #25283 October 12, 2026 12:19
@JPeer264
JPeer264 marked this pull request as ready for review October 12, 2026 12:31
@JPeer264
JPeer264 requested a review from a team as a code owner October 12, 2026 12:31
@JPeer264
JPeer264 requested review from nicohrubec and s1gr1d and removed request for a team October 12, 2026 12:31
@JPeer264 JPeer264 self-assigned this Oct 12, 2026
@JPeer264
JPeer264 requested a review from chargome October 12, 2026 12:31
@JPeer264
JPeer264 force-pushed the jp/flaky-nextjs-debug-build-mock branch from e183f8f to b3a6ebd Compare October 12, 2026 12:33

@nicohrubec nicohrubec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean

@JPeer264
JPeer264 removed this pull request from stack #25283 October 13, 2026 15:29
@JPeer264
JPeer264 added this pull request to stack #25335 October 13, 2026 15:29
…g the SDK

The test mocked DEBUG_BUILD with vi.doMock, then called vi.resetModules
and imported the client, server and edge entry points again in each
test. Vitest had to evaluate three large module graphs every time, and
beforeAll "pre-warmed" them once more. Under CI load this took longer
than the 10s hook timeout.

The entry points read DEBUG_BUILD inside init(), so one top-level
vi.mock with a getter over a vi.hoisted value lets each test switch it.
The entry points are imported once, and the tests take milliseconds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JPeer264
JPeer264 force-pushed the jp/flaky-nextjs-debug-build-mock branch from b3a6ebd to 412d5db Compare October 13, 2026 15:36
@JPeer264
JPeer264 merged commit 3e02739 into develop Oct 14, 2026
93 of 121 checks passed
@JPeer264
JPeer264 deleted the jp/flaky-nextjs-debug-build-mock branch October 14, 2026 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants