Skip to content

fix(sentry): give the server SDK the release the client already had (#15) - #22

Merged
arpitdalal merged 2 commits into
mainfrom
issue-15-server-release
Sep 29, 2026
Merged

arpitdalal merged 2 commits into
mainfrom
issue-15-server-release

Conversation

@arpitdalal

Copy link
Copy Markdown
Owner

Closes #15. Depends on #16 (PR #20, #21) and only makes sense on top of it.

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 still reached vite.config.ts, which is exactly why the client always looked right and this stayed invisible.
  • server/utils/monitoring.ts sets release explicitly, 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: filesToDeleteAfterUpload runs in the plugin's writeBundle finally whether 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:

> Uploaded files to Sentry
  Source Map Upload Report
    Scripts
      ~/74f74707-….js (sourcemap at index.js.map, debug id 74f74707-…)
      ~/950ab4f9-….js (sourcemap at server-build-5Ewr5zou.js.map, debug id 950ab4f9-…)

Verified before the fix, so the numbers are not inferred

$ flyctl ssh console --app arpitdalal-dev-256c
root@9080e30da734d8:/myapp# printenv COMMIT_SHA
                                   # empty

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, because ARG alone is build-time-only and ENV is what the process reads.
  • tags the SDK with the release, which mocks @sentry/node and asserts on the value that reaches Sentry.init rather than regexing the line that sets it. init() is callable, so there was no reason to assert on source text.

npm run validate clean · 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 no git binary. 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 running sentry-cli releases set-commits from the deploy job where a checkout exists. Filing that separately rather than folding it in here.

Also still open: SENTRY_ORG is now redundant given the sntrys_ org token, and the legacy 2024 personal token should be revoked in Sentry.

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.
@coderabbitai

coderabbitai Bot commented Sep 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 33 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: d9eb3e68-26c9-451e-8284-e6e4b4f80e2d

📥 Commits

Reviewing files that changed from the base of the PR and between ec64fbe and fc67092.

📒 Files selected for processing (3)
  • other/Dockerfile
  • server/utils/monitoring.ts
  • tests/sentry-release.test.ts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@arpitdalal
arpitdalal merged commit bcd65e4 into main Sep 29, 2026
6 checks passed
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.

Server-side Sentry events carry no release — COMMIT_SHA is dropped at the end of the Docker build stage

1 participant