feat(worker): add Sentry error tracking and source maps for debuggable builds - #547
Open
realcodesiman wants to merge 1 commit into
Open
feat(worker): add Sentry error tracking and source maps for debuggable builds#547realcodesiman wants to merge 1 commit into
realcodesiman wants to merge 1 commit into
Conversation
…e builds Make bundled worker processes debuggable in production by emitting source maps and wiring Sentry to remap and report errors back to TypeScript sources. - Emit source maps from tsdown and run node with --enable-source-maps so stack traces from bundled .mjs map back to the original .ts - Initialize Sentry via instrument.ts loaded with node --import, ahead of every worker; a missing SENTRY_DSN disables it as a no-op - Add sentry helpers (captureException, reportJobFailure, flushSentry) that guard on init, report only final job attempts, and attach identifiers rather than raw job.data to avoid leaking contact PII - Pass debug/observability flags directly in docker-entrypoint so a runtime NODE_OPTIONS cannot clobber them - Document SENTRY_* and WORKER_NAME in .env.example and validate them in env.ts
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.
Summary
.mjsoutput is hard to debug: stack traces point at minified-ish bundles, and unhandled errors vanish without a trace in production.SENTRY_DSNmakes every Sentry helper a no-op.Changes
apps/worker/tsdown.config.ts— emit source maps; addsrc/instrument.tsas a build entry.apps/worker/src/instrument.ts— initialize Sentry fromprocess.envbefore any worker module loads; missing DSN disables it.apps/worker/src/lib/sentry.ts—captureException,reportJobFailure(final attempt only, identifiers not rawjob.data),flushSentry(best-effort), all guarded by init.apps/worker/src/chat/worker.ts— capture bootstrap failures and report job failures.docker/.../docker-entrypoint.sh— run node with--enable-source-maps --import instrument.mjs, passed directly so a runtimeNODE_OPTIONScan't clobber them; validate the instrument script before starting.apps/worker/src/env.ts+.env.example— document/validateSENTRY_*andWORKER_NAME.apps/worker/package.json+pnpm-lock.yaml— add@sentry/node.Test plan
SENTRY_DSNunset (no-op path)SENTRY_DSN, force a job failure, confirm event arrives with mapped TS stack trace and nojob.dataPII