Repository navigation
fix(sentry): give the server SDK the release the client already had (#15) - #22
Merged
Merged
Conversation
The client bundle gets SENTRY_RELEASE injected by the Sentry plugin. The server got nothing: there is no global scope in Node for the plugin to write to, and @sentry/node has no SENTRY_RELEASE env fallback of its own — grepping the installed package returns no hits. So every server-side event went out with no release, and since ~99% of this project's error volume is server-side, that is nearly all of it. Two changes, and neither is sufficient alone: - other/Dockerfile redeclares COMMIT_SHA in the final stage. ARG does not cross a FROM, so the build stage's declaration left the running container with no idea which commit it was. The value reaches vite.config.ts either way, which is why the client always looked right. - server/utils/monitoring.ts sets `release` explicitly rather than relying on an injected global, which also keeps working if the bundler integration is ever dropped. Closes #15. The source maps this depends on only started uploading with #16: filesToDeleteAfterUpload runs in the plugin's writeBundle `finally` whether or not the upload succeeded, so before then the server bundle's maps were generated and then deleted. The last deploy's log now shows server-build-*.js uploading alongside the client bundles.
Function declarations hoist, so it worked where it was — two hundred lines below its only use site, and below the describe block that reads it. Grouped with buildStage() so the two halves of the Dockerfile are described side by side.
|
Warning Review limit reachedNext included review available in 33 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Closes #15. Depends on #16 (PR #20, #21) and only makes sense on top of it.
The client bundle gets
SENTRY_RELEASEinjected by the Sentry plugin. The server got nothing: there is no global scope in Node for the plugin to write to, and@sentry/nodehas noSENTRY_RELEASEenv fallback of its own — grepping the installed package returns no hits. So every server-side event went out with no release, and since ~99% of this project's error volume is server-side, that is nearly all of it.Two changes, and neither is sufficient alone:
other/DockerfileredeclaresCOMMIT_SHAin the final stage.ARGdoes not cross aFROM, so the build stage's declaration left the running container with no idea which commit it was. The value still reachedvite.config.ts, which is exactly why the client always looked right and this stayed invisible.server/utils/monitoring.tssetsreleaseexplicitly, so the association also survives the bundler integration being removed.The caveat in the original issue is resolved in the affirmative
It warned that server symbolication was newly in play and might surface mapping problems. It does not — because of what #16 revealed:
filesToDeleteAfterUploadruns in the plugin'swriteBundlefinallywhether or not the upload succeeded. Before #16, the server bundle's maps were generated and then deleted, never uploaded. The last deploy's log now shows both halves uploading:Verified before the fix, so the numbers are not inferred
Tests
Two, both mutation-checked — reverting each half of the fix fails the test that covers it, so neither passes vacuously:
redeclares COMMIT_SHA in the runtime stage, becauseARGalone is build-time-only andENVis what the process reads.tags the SDK with the release, which mocks@sentry/nodeand asserts on the value that reachesSentry.initrather than regexing the line that sets it.init()is callable, so there was no reason to assert on source text.npm run validateclean · 202 tests · CodeRabbit clean.What this does not do
Commit association still does not work, and this does not change that.
setCommits: { auto: true }needs a git repository and the build stage has nogitbinary. PR #20 removed the option so the plugin's tolerant default applies and the release still finalizes, but releases will have zero associated commits — so the suspect-commit and commit-context features stay dark. Fixing it properly means a Sentry GitHub integration, or runningsentry-cli releases set-commitsfrom the deploy job where a checkout exists. Filing that separately rather than folding it in here.Also still open:
SENTRY_ORGis now redundant given thesntrys_org token, and the legacy 2024 personal token should be revoked in Sentry.