fix: restore Sentry release tag from spawned telemetry worker#3801
Open
eablack wants to merge 3 commits into
Open
fix: restore Sentry release tag from spawned telemetry worker#3801eablack wants to merge 3 commits into
eablack wants to merge 3 commits into
Conversation
The CLI version is stored in a module-level variable in the main process and read back by SentryClient.ensureInitialized when the worker calls Sentry.init. Since the worker runs in a separate Node process spawned via spawnTelemetryWorker, that module state does not carry across — getVersion() returns 'unknown' and every event from CLI >= 11.2.0 has release=unknown in Sentry. Wrap every worker payload in a WorkerEnvelope so the version rides across the process boundary, and re-hydrate it before any client initialization. W-23296430
- Make parseWorkerEnvelope pure. It now returns {cliVersion, payload}
and the worker calls setVersion explicitly at the top of the stdin
handler, so the ordering "hydrate before any client init" is visible
at the call site instead of hidden inside a read-shaped helper.
- Discriminate non-Error variants of WorkerData exhaustively in
serializeTelemetryData. Adding a new variant now produces a compile
error at the serializer instead of falling through the else branch.
- Narrow RecordOpts.Command from oclif's Command.Class to
HerokulyticsData['Command']. The producer in the prerun hook and the
worker both build exactly this shape; the wider type was hiding the
divergence risk that made the double-cast in the worker necessary.
Cast removed.
W-23296430
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
Since the background-worker refactor in v11.2.0 (
c13074da5), every Sentry event captured by the CLI is taggedrelease: unknown. The version cached viasetVersionintelemetry-utils.tslives in module-level state in the main process; the telemetry worker runs in a separate spawned Node process, sogetVersion()returns'unknown'whenSentryClient.ensureInitializedcallsSentry.init({ release }).Confirmed in the
heroku-mk/cliSentry project — no release tag exists for any 11.1.x → 11.8.0 build;unknown(4.27M events) is the only bucket still receiving events.The fix wraps every worker payload in a
WorkerEnvelope({ cliVersion, payload }) — the sole contract betweenserializeTelemetryDataand the worker entrypoint. The worker'sreadWorkerEnvelopehelper restores the version viasetVersionbefore any client initialization runs. No optional fields, no runtime shape checks.Type of Change
Patch Updates (patch semver update)
Testing
Notes:
The OTEL/Honeycomb path is unchanged. The only behavioral effect on OTEL is that the tracer version string (
tracer('heroku-cli', getVersion())) will now be the actual CLI version instead of'unknown'— a correction rather than a break.Steps:
npm run build).releasetag instead ofunknown.Screenshots (if applicable)
Related Issues
GitHub issue: #N/A
GUS work item: W-23296430