ref(server-utils): Move server-only utils out of core - #23826
Draft
mydea wants to merge 1 commit into
Draft
Conversation
Moves a batch of server-only helpers out of `@sentry/core/server` into `@sentry/server-utils`, continuing the effort to slim `@sentry/core` down to the isomorphic surface. The moved symbols only ever depended on the public `@sentry/core` API (plus the `@sentry/core/server` `filenameIsInApp` for anr), so they relocate cleanly without expanding core's public surface. Moved: - `flushIfServerless` + `vercelWaitUntil` (used by the meta-framework SDKs) - `trpcMiddleware` - `callFrameToStackFrame` / `watchdogTimer` (the anr worker helpers) - `loadModule` (split out of `utils/node`, `isNodeEnv` stays in core since core itself depends on it via `isBrowser`) Every consumer already depends on `@sentry/server-utils`, so this only changes the internal import path; the public SDK packages keep re-exporting these under the same names, so there is no user-facing change. `mcp-server` and the `integrations/http/*` subtree are intentionally left in core for now: unlike the above, they import a number of non-public core internals (`getSpanName`, `resolveDataCollectionOptions`, `getBreadcrumbLogLevel`, `getDefaultExport`, `generatePropagationContext`, the internal `client`/`scope` modules), so moving them would require promoting those to core's public API — a separate decision. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 172fba6. Configure here.
| export type { ServerRuntimeOptions } from './types/options'; | ||
| export { trpcMiddleware } from './trpc'; | ||
| export { wrapMcpServerWithSentry } from './integrations/mcp-server'; | ||
| export { isNodeEnv, loadModule } from './utils/node'; |
There was a problem hiding this comment.
Leftover import of removed export
Medium Severity
flushIfServerless was removed from @sentry/core/server, but the nuxt-3 e2e app still imports it from that path. That application will fail to start, so the e2e suite that exercises the custom Nitro error handler no longer runs.
Reviewed by Cursor Bugbot for commit 172fba6. Configure here.
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.


Continues slimming
@sentry/coretoward the isomorphic surface by moving a batch of server-only helpers out of@sentry/core/serverinto@sentry/server-utils(following the same pattern as the browser span-API move).Moved to
@sentry/server-utils:flushIfServerless+vercelWaitUntiltrpcMiddlewarecallFrameToStackFrame/watchdogTimer(anr worker helpers)loadModule(split out ofutils/node)Why these are safe to move: each only depended on the public
@sentry/coreAPI (anr additionally usesfilenameIsInAppfrom@sentry/core/server, which stays), so nothing in core's public surface had to be expanded. Every consumer already depends on@sentry/server-utils, so this only changes the internal import path — the public SDK packages (@sentry/node,@sentry/nextjs, …) keep re-exporting these under the same names, so there is no user-facing change.Decisions:
isNodeEnvstays in@sentry/core: core itself depends on it (viaisBrowser), so it cannot move without a cycle.loadModulewas split out of the sameutils/nodefile.mcp-serverand theintegrations/http/*subtree are deliberately left in core. Unlike the helpers above, they import several non-public core internals (getSpanName,resolveDataCollectionOptions,getBreadcrumbLogLevel,getDefaultExport,generatePropagationContext, and the internalclient/scopemodules). Moving them would require promoting those internals to core's public API, which is a separate call to make.@sentry/server-utilsand rewritten to spy on the public@sentry/corenamespace; consumer test mocks were retargeted from@sentry/core/serverto@sentry/server-utils(using light full-replacement mocks rather thanimportOriginal, to avoid force-loading the whole server-utils integration graph).