Repository navigation
test(bun): Restore @sentry/core spies after the Bun.serve tests - #25276
Merged
Merged
Conversation
JPeer264
added this pull request to stack #25283
October 12, 2026 12:19
JPeer264
marked this pull request as ready for review
October 12, 2026 12:21
JPeer264
requested review from
isaacs and
mydea
and removed request for
a team
October 12, 2026 12:21
andreiborza
approved these changes
Oct 12, 2026
nicohrubec
approved these changes
Oct 13, 2026
JPeer264
removed this pull request from stack #25283
October 13, 2026 15:29
JPeer264
added this pull request to stack #25335
October 13, 2026 15:29
bunserver.test.ts replaces startSpanManual, continueTrace and captureException of @sentry/core and never restores them. In Bun the spies stay for every later test file in the same process, so when bunHttpServer.test.ts runs next, its handler gets no active span. The test file order of bun test follows the directory listing. On GitHub runners bunRuntimeMetrics.test.ts ran in between and its jest.restoreAllMocks() removed the spies; on Namespace runners it does not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JPeer264
force-pushed
the
jp/flaky-bun-serve-spies
branch
from
October 13, 2026 15:36
83d7d75 to
f682bd3
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This restores the
@sentry/corespies thatbunserver.test.tscreates (startSpanManual,continueTraceandcaptureException) in anafterAll.Why
bun testruns all test files in one process, in the order in which the filesystem lists them. The spies stayed active for the next files, so whenbunHttpServer.test.tsran next, its request handler had no active span and two tests failed. On GitHub runnersbunRuntimeMetrics.test.tsran in between, and itsjest.restoreAllMocks()hid the bug. Other runners list the files in a different order.In that file order on Linux with Bun 1.3.14, 2 of 81 tests failed before this change, and all 81 pass after it.
Failed on CI: https://github.com/getsentry/sentry-javascript/actions/runs/38031083791/job/114152141693