fix: ENGINE_VERSION genuinely reads package.json (telemetry reported 4.4.0 while on 4.5.0) - #208
Open
thunpisit wants to merge 1 commit into
Open
fix: ENGINE_VERSION genuinely reads package.json (telemetry reported 4.4.0 while on 4.5.0)#208thunpisit wants to merge 1 commit into
thunpisit wants to merge 1 commit into
Conversation
`ENGINE_VERSION` was a hardcoded `"4.4.0"` literal under a comment that already claimed it was "Sourced from package.json at build time". It was not. package.json reached 4.5.0 in #206 and the constant did not, so every install with telemetry enabled has been reporting a version it is not running — silently, because nothing compared the two. That field is `engineVersion` in the telemetry payload, and it is the one the maintainer most needs to be true: it answers "can we drop 3.x yet?" and it is the input any future upgrade checker would compare a release against. A version checker built on a stale constant would offer a fork the upgrade it already has, or hide the one it needs. The fix imports package.json directly. `resolveJsonModule` is already on (tsconfig.json), and Rollup inlines the single accessed property at build time — verified in the emitted bundle, which carries the string literal "4.5.0" with no JSON parse and no file read on the Worker. `engine-version.node.test.ts` pins it three ways: 1. VALUE — the constant equals package.json's `version`. 2. SHAPE — it is bare semver, since telemetry groups on this field and a stray `v` prefix would fragment the histogram silently. 3. SOURCE — the declaration contains no version-shaped string literal, and the module does reach package.json. (3) is the one that matters. (1) alone is satisfiable by retyping the new number by hand, which restores the exact bug this commit fixes. Both (1) and (3) were confirmed to fail against the pre-fix source. Also refreshes the stale "4.4.0" examples in docs/TELEMETRY.md and the `engineVersion` doc comment in telemetry/payload.ts. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
The bug
src/lib/server/telemetry/index.ts:50was:The comment was already making a claim the code did not honour — it is a hardcoded literal.
package.jsonmoved to4.5.0in #206 and the constant stayed behind, so every install with telemetry enabled has been reporting a version it is not running, silently, because nothing compared the two.Why this one matters more than a stale string
engineVersionis the payload field that answers "can we drop support for 3.x yet?" (docs/TELEMETRY.md). It is also the input any future upgrade checker compares a published release against. A checker built on a constant that drifts would offer a fork an upgrade it already has — or hide the one it needs.The fix
Import
package.jsondirectly.resolveJsonModuleis already enabled intsconfig.json, and Rollup inlines the single accessed property at build time. Verified in the emitted bundle (.svelte-kit/output/server/entries/endpoints/api/telemetry/cron/_server.ts.js): it carries the string literal"4.5.0", with no JSON parse and no file read on the Worker at runtime.The test
src/lib/server/telemetry/engine-version.node.test.tspins it three ways:package.json'sversion.vprefix or build suffix would fragment the histogram silently.package.json.(3) is the one that matters. (1) alone is satisfiable by retyping the new number by hand, which restores the exact bug being fixed here. Both (1) and (3) were confirmed to fail against the pre-fix source before being committed.
Also refreshes the stale
4.4.0examples indocs/TELEMETRY.mdand theengineVersiondoc comment intelemetry/payload.ts.Gate
pnpm run checkpnpm run lintpnpm run testpnpm run buildpnpm run guard:contractpnpm run guard:cssFollow-up
This surfaced while researching a one-click upgrade flow for
/admin; that design proposal is filed separately. The dependency is direct: an upgrade checker cannot be built on a version constant that lies.