Skip to content

fix: tolerate npm publish-time scanning delays - #7

Merged
FlyOverCoderKY merged 4 commits into
mainfrom
claude/fix-npm-publish
Nov 11, 2026
Merged

FlyOverCoderKY merged 4 commits into
mainfrom
claude/fix-npm-publish

Conversation

@FlyOverCoderKY

@FlyOverCoderKY FlyOverCoderKY commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

The v0.2.0 upload was accepted, but publication failed after only 31 seconds of registry polling while npm was still scanning the package. The exact original artifact later appeared unchanged. npm documents a typical five-minute delay and sometimes 15 minutes or longer.

Wait up to 20 minutes after one accepted upload, with at most 41 read-only lookups and 30-second polling intervals. Preflight and recovery require known absence or authenticated existing package bytes. Following one accepted upload, bounded confirmation polling tolerates transient network, throttling and server failures. Authentication and byte conflicts stop the attempt. Keep an actionable timeout and document recovery using the original immutable artifact; no version, tag, or package bytes change.

Validation: Node 22.18.0 and Node 24.18.0 formatting, type checks, full tests, package release check, and synthetic example passed. Each lane passed 153 runtime tests and 139 release regression cases; three Windows file-symlink cases require Linux CI. Independent read-only correctness/security review found no remaining blockers. Focused regressions cover 16-minute visibility delay, one upload, exhausted polling, a stationary clock, slow requests, and immediate rejection of unknown registry states. Existing Windows file-symlink tests skip without Developer Mode; required Linux CI must execute them.

Release recovery: original artifact preflight and independent strict registry verification passed, including npm signatures, exact source-bound provenance, and a clean exact-version consumer. The failed-jobs-only rerun of Publish 42890853173 completed successfully after maintainer approval. Its separate registry/provenance/consumer verification passed; npm latest is 0.2.0. Recovery used original artifact 13797618536 and independent manifest SHA-256 4ecc15c08cde8ea103799d5d5da91bac1730864352c762cdb01ce2c9a282d81b. The original tag was not moved and the artifact was not rebuilt.

Reference: https://github.blog/changelog/2026-07-28-npm-publish-time-malware-scanning-and-dual-use-metadata/

The follow-up uses a monotonic clock and performs the final bounded lookup after the last polling sleep. Regression cases cover final-interval visibility, request latency, timer overshoot and wall-clock jumps. Recovery documentation now downloads the original artifact before invoking preflight.

Current local validation passed all normal commands on Node 22 and 24, with 153 runtime tests and 171 release tests per lane. The three Windows symlink cases await the current Linux CI run.

The confirmation-only retry path now covers temporary metadata, canonical tarball and response-body failures. Retry-After is honored within the existing deadline and lookup budget. Preflight and pre-write unknown-state rejection is exercised by the existing regressions. The public-entry tests require one upload and positive exact-byte confirmation.

The remaining confirmation cleanup finding is fixed. Body cleanup handles rejection and starts cancellation without waiting for an unbounded acknowledgement. A real old-source regression failed before the fix. Accepted-upload recovery, polling exhaustion and later authentication/exact-byte refusals pass while preserving one upload and the existing deadline/poll bounds. Both Node 22 and 24 passed all normal formatting, types, runtime, release and protocol-example gates. Each lane passed 153 runtime cases and 184 release cases, with the three established Windows symlink skips. Fresh Linux CI must execute all 187 release cases. Current-head code review is handled by the configured OpenRouter action.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-10T21:28:41.541846Z 7915455 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

OpenRouter review posted (clean). #7 (review)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenRouter pull-request review

Verdict: issues
Scope: full-pr (full-pr)
Mode: initial
Commit: 791545512cf4a3cc5f3ca2d27bd744397eac8f08
Judge: openai/gpt-5.6-luna
Cost: $0.1247 (lanes $0.1216 + judge $0.0031)

Lanes

  • openai/gpt-6.1-sol: ok (2 finding(s), 49.7s, 83855+1843 tokens (57701 cached), 4 tool round(s), via Azure, $0.0985)
  • z-ai/glm-5.3-flash: ok (4 finding(s), 296.2s, 515967+31868 tokens (340992 cached), 11 tool round(s), via PrimeIntellect, $0.0231)

Findings

🟠 Issue 1 — Final polling interval ends without a registry check

scripts/release-registry.mjs:609 · risk · identified by openai/gpt-6.1-sol

If npm makes the version visible during the final sleep—for example, at 19 minutes 45 seconds—the publisher can report a timeout without checking the now-visible version. This creates an avoidable failed release and manual recovery despite visibility arriving within the waiting budget.

confirmRegistry sleeps through the remaining deadline, then the now() >= deadline guard prevents the next lookup. With instantaneous lookups, it checks at 0 through 19:30, sleeps until 20:00, and exits; the nominal 41st check never occurs. Request latency likewise leaves an unchecked final interval. Consider allowing one final bounded lookup after that sleep, consistent with the documented allowance for in-flight verification.

I checked the caller in publishPreparedRelease, the request timeouts, and the new polling regressions. The stationary-clock test reaches 41 checks only because its clock never reaches the deadline; the advancing-clock tests do not cover a version becoming visible during the final sleep.

🟠 Issue 2 — Elapsed-time deadline uses an adjustable wall clock

scripts/release-registry.mjs:602 · risk · identified by openai/gpt-6.1-sol

A forward adjustment of the runner's system clock during scanning can terminate polling before 20 minutes have actually elapsed. A backward adjustment can extend polling beyond the stated elapsed-time budget, particularly when requests themselves are slow.

The new deadline uses Date.now, which measures wall time rather than monotonic elapsed time. The 41-lookup cap limits request count but does not make the elapsed deadline immune to clock changes. Use a monotonic production clock, such as performance.now, while retaining the injectable test seam.

I checked publishPreparedRelease, .github/workflows/publish.yml, and the polling tests. The 30-minute hosted-job timeout supplies an outer bound, but does not preserve the internal 20-minute budget. Tests cover a stationary clock and request latency, not clock adjustments. There is no evidence that this runner has experienced such an adjustment; this is a clock-correction failure scenario rather than an observed incident.

🟠 Issue 3 — A single transient registry error during the 20-minute scan window aborts publication and forfeits the whole wait

scripts/release-registry.mjs:611 · risk · identified by z-ai/glm-5.3-flash

Failure scenario: the upload is accepted at T0, npm's exact-version endpoint answers 404 for 19 minutes, and then one poll hits a transient 503, 429, or a dropped connection. registryRecord treats every non-200/non-404 status as fatal and request turns any fetch rejection into a fatal error, so confirmRegistry throws on that single poll — the job goes red after ~19 minutes of otherwise-successful waiting, and recovery requires a full rerun of the protected publish job, the exact outcome this change exists to avoid. The window grew from ~31 s to 20 minutes, and registry load during mass scanning periods makes a transient 5xx/429 inside that window plausible rather than exotic.

Related instances of the same mechanism (single registry hiccup destroys the whole attempt):

  • Even after the wait succeeds, verifyPublishedBytes runs preflightRegistry as a single pass with no tolerance; one flaky metadata fetch or tarball read immediately after the 20-minute wait still fails the job.
  • If npm's scan-holding state ever surfaces as anything other than 404 (e.g., 403/451 while the version is quarantined pending review), the very first poll fails and the new patience window never engages at all — the change only tolerates invisibility in the 404 shape.

Evidence: registryRecord (scripts/release-registry.mjs, status checks around lines 96-104) fails on any status other than 200/404, and confirmRegistry has no tolerance around the per-poll call at line 611. Counterevidence I weighed: this is a deliberate policy — the PR states "Unknown registry states and byte conflicts still fail immediately" and tests/release/registry.test.mjs lines 558-590 newly pin immediate failure for 401/429/503/network; the "rerun only the failed jobs" recovery in docs/RELEASING.md mitigates but does not remove the cost of a red protected job plus ~20 sunk minutes. Reported as a risk trade-off, not an unintended regression.

🟠 Issue 4 — Worst-case publish-job runtime sits within a couple of minutes of the 30-minute job timeout

docs/RELEASING.md:225 · risk · identified by z-ai/glm-5.3-flash

Failure scenario: npm publish stalls near its 5-minute nativeRun cap while npm is scanning, the scan delay then consumes the full 20-minute confirmRegistry deadline, and the post-wait verifyPublishedBytes (metadata + tarball, each capped at 30 s) adds up to another minute. With ~1-2 minutes of job setup (uncached setup-node 24.18.0 download, the npm setup action, artifact download) the publish job reaches roughly 28-29 minutes against timeout-minutes: 30 in .github/workflows/publish.yml. The job can then be killed after npm accepted the upload but before the in-job byte verification completes — a red run with a perfectly good artifact. Recovery is documented, but the doc's claim that "The 30-minute job timeout remains the outer bound" glosses over that the bound can fire mid-verification at the tail rather than cleanly after it.

Evidence for the arithmetic: nativeRun caps npm at 5 * 60_000 (scripts/release-registry.mjs), confirmRegistry is bounded by 20 * 60_000 plus at most ~60 s of in-flight metadata/tarball work (which the new doc paragraph itself acknowledges), and the publish job's timeout-minutes: 30 is unchanged. Proof gap: the setup-step durations are my estimate from the workflow steps; with a warm cache and a fast publish the margin is comfortable, so this is a tail-risk about the pathological combination the PR is designed to survive, not a certainty.

🔵 Issue 5 — Recovery instructions present 'artifact ID' as a preflight input, but preflight accepts no artifact ID

docs/RELEASING.md:229 · nit · identified by z-ai/glm-5.3-flash

An operator following the new recovery paragraph during a real incident would run preflight "with the original artifact ID, independent manifest digest, tag, and commit" — but preflight has no artifact-ID input. parseArguments in scripts/release-packages.mjs accepts only --prepared-dir, --manifest-sha256, --tag, and --expected-commit for preflight/publish/verify, and preflightRegistry receives only the verified manifest. The artifact ID is a workflow-artifact concept consumed by the rerun's download-artifact step, not a preflight flag, so the sentence cannot be executed literally as written; the prepared directory has to be reconstructed from the artifact first, which the text does not say.

Evidence: docs/RELEASING.md line 229 versus the keys mapping in parseArguments and preflightRelease in scripts/release-packages.mjs. Nothing else in the repo defines an artifact-ID input for preflight, so I found no counterevidence.

🔵 Issue 6 — Scan-delay figures cite a changelog post whose contents cannot be verified from the repository

docs/RELEASING.md:219 · nit · identified by z-ai/glm-5.3-flash

The new paragraph asserts npm's scan "normally takes about five minutes and can take 15 minutes or longer", citing a github.blog changelog URL, and these figures calibrate the chosen 20-minute deadline and the recovery expectations. The link and the numbers entered the documentation from the untrusted PR description; if the cited post does not actually state those timings (or the delay is not attributable to malware scanning), the docs overclaim npm's documented behavior and operators calibrate waiting/recovery against unsupported figures.

Evidence and proof gap: I have no network access in this review, so I could not confirm the URL resolves or supports the quoted timings; I could only check internal consistency — the 2026-07-28 post date is chronologically plausible next to the repository's 2026-11-dated records (e.g., docs/BOOTSTRAP.md). This is a verify-manually nit, not a demonstrated factual error.

Workflow run

Comment thread scripts/release-registry.mjs Resolved
Comment thread scripts/release-registry.mjs Resolved
Comment thread scripts/release-registry.mjs Resolved
Comment thread docs/RELEASING.md Outdated
20-minute deadline (in-flight metadata and tarball verification can take up to
60 additional seconds).
Unknown registry states and conflicting bytes still fail immediately. The
30-minute job timeout remains the outer bound. An unavailable version at the

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Worst-case publish-job runtime sits within a couple of minutes of the 30-minute job timeout (risk)

Failure scenario: npm publish stalls near its 5-minute nativeRun cap while npm is scanning, the scan delay then consumes the full 20-minute confirmRegistry deadline, and the post-wait verifyPublishedBytes (metadata + tarball, each capped at 30 s) adds up to another minute. With ~1-2 minutes of job setup (uncached setup-node 24.18.0 download, the npm setup action, artifact download) the publish job reaches roughly 28-29 minutes against timeout-minutes: 30 in .github/workflows/publish.yml. The job can then be killed after npm accepted the upload but before the in-job byte verification completes — a red run with a perfectly good artifact. Recovery is documented, but the doc's claim that "The 30-minute job timeout remains the outer bound" glosses over that the bound can fire mid-verification at the tail rather than cleanly after it.

Evidence for the arithmetic: nativeRun caps npm at 5 * 60_000 (scripts/release-registry.mjs), confirmRegistry is bounded by 20 * 60_000 plus at most ~60 s of in-flight metadata/tarball work (which the new doc paragraph itself acknowledges), and the publish job's timeout-minutes: 30 is unchanged. Proof gap: the setup-step durations are my estimate from the workflow steps; with a warm cache and a fast publish the margin is comfortable, so this is a tail-risk about the pathological combination the PR is designed to survive, not a certainty.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 30-minute publisher job is an intentional outer bound. The handbook now explains that setup, the native command, polling and verification can reach that bound and leave an interrupted outcome. Recovery uses the original artifact with fresh authenticated preflight. The change provides bounded visibility polling and preserves the workflow outer limit.

Comment thread docs/RELEASING.md Resolved
Comment thread docs/RELEASING.md

npm accepts uploads before its
[publish-time malware scan](https://github.blog/changelog/2026-07-28-npm-publish-time-malware-scanning-and-dual-use-metadata/)
makes the version available. This normally takes about five minutes and can take

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Scan-delay figures cite a changelog post whose contents cannot be verified from the repository (nit)

The new paragraph asserts npm's scan "normally takes about five minutes and can take 15 minutes or longer", citing a github.blog changelog URL, and these figures calibrate the chosen 20-minute deadline and the recovery expectations. The link and the numbers entered the documentation from the untrusted PR description; if the cited post does not actually state those timings (or the delay is not attributable to malware scanning), the docs overclaim npm's documented behavior and operators calibrate waiting/recovery against unsupported figures.

Evidence and proof gap: I have no network access in this review, so I could not confirm the URL resolves or supports the quoted timings; I could only check internal consistency — the 2026-07-28 post date is chronologically plausible next to the repository's 2026-11-dated records (e.g., docs/BOOTSTRAP.md). This is a verify-manually nit, not a demonstrated factual error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The official GitHub npm changelog documents typical five-minute scanning delays and possible delays of fifteen minutes or longer at peak load. The handbook now describes those as observations with no service-time guarantee. Official changelog

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenRouter pull-request review

Verdict: issues
Scope: latest-commit (commit-range)
Mode: verify
Commit: c198236d4104f93f4bc85b510c45e9e26a343636
Judge: openai/gpt-5.6-luna
Cost: $0.0921 (lanes $0.0919 + judge $0.0001)

Lanes

  • openai/gpt-6.1-sol: ok (0 finding(s), 27.6s, 64755+1096 tokens (46943 cached), 4 tool round(s), via Azure, $0.0662)
  • z-ai/glm-5.3-flash: ok (0 finding(s), 237.1s, 350224+26471 tokens (175104 cached), 10 tool round(s), via PrimeIntellect, $0.0257)

Round 2 resolution

  • ✅ r1-1 fixed correctly — Final polling interval ends without a registry check: confirmRegistry no longer checks the deadline before the lookup following a scheduled sleep. It performs that final lookup, then stops if the version remains absent and the budget is exhausted; the 41-attempt cap remains intact.

New regressions cover visibility during the final interval with instantaneous requests, request latency, and timer overshoot.

  • ✅ r1-2 fixed correctly — Elapsed-time deadline uses an adjustable wall clock: The production clock now uses performance.now() while preserving the injectable seams.now clock. Polling therefore measures monotonic elapsed time rather than adjustable wall time.

The new tests remove the injected clock and exercise forward and backward Date.now() adjustments against mocked monotonic time.

  • ❌ r1-3 not fixed — A single transient registry error during the 20-minute scan window aborts publication and forfeits the whole wait: A transient network error, HTTP 429, or HTTP 503 still aborts the post-upload polling window immediately. request throws on fetch rejection, registryRecord throws on every non-200/non-404 status, and confirmRegistry does not catch those failures.

The existing post-publication regression explicitly expects immediate failure without any sleep for these cases, and the documentation retains…

  • 🤝 r1-4 disputed — Worst-case publish-job runtime sits within a couple of minutes of the 30-minute job timeout: The structural facts are unchanged: publish.yml keeps timeout-minutes: 30 (line 241) and the worst case (publish up to the ~5-minute cap + 20-minute monotonic wait + final lookup + up to 60 s byte verification + job setup) can still press against it — the now-guaranteed final lookup even adds up to ~30 s versus the prior commit. What this commit does is make the tradeoff explicit and safe: docs/…
  • 2 nit finding(s) from earlier rounds retired (severity floor for follow-up rounds is risk).
  • Open findings after this round: 1 (0 bug-severity).

No structured findings from the successful lane(s).

Workflow run

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenRouter pull-request review

Verdict: issues
Scope: full-pr (full-pr)
Mode: verify
Commit: c96de2eade2638dd80db35d62d17e52e6f82dda1
Judge: openai/gpt-5.6-luna
Cost: $0.1529 (lanes $0.1528 + judge $0.0001)

Lanes

  • openai/gpt-6.1-sol: ok (0 finding(s), 43.4s, 96419+1607 tokens (61374 cached), 3 tool round(s), via Azure, $0.12)
  • z-ai/glm-5.3-flash: ok (0 finding(s), 410.0s, 510773+20383 tokens (456960 cached), 11 tool round(s), via Modal, $0.0320)

Round 3 resolution

  • ⚠️ r1-3 fixed incorrectly — A single transient registry error during the 20-minute scan window aborts publication and forfeits the whole wait: The main retry path is implemented, but a transport-error escape remains during the 404 polling window. In scripts/release-registry.mjs:157, the 404 branch awaits response.body?.cancel() without guarding cleanup errors. If fetch returns 404 headers and the body subsequently errors—for example, from a dropped connection or the request timeout—Web Streams cancellation rejects with the stored str…
  • Open findings after this round: 1 (0 bug-severity).

No structured findings from the successful lane(s).

Workflow run

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenRouter pull-request review

Verdict: clean
Scope: latest-commit (commit-range)
Mode: verify
Commit: a79480e1bb96df2da8e0b0059e0fa21f5068c13a
Judge: openai/gpt-5.6-luna
Cost: $0.1010 (lanes $0.1009 + judge $0.0001)

Lanes

  • openai/gpt-6.1-sol: ok (0 finding(s), 21.4s, 61452+824 tokens (38465 cached), 3 tool round(s), via Azure, $0.0765)
  • z-ai/glm-5.3-flash: ok (0 finding(s), 135.5s, 421961+13071 tokens (244800 cached), 17 tool round(s), via Together, $0.0244)

Round 4 resolution

  • ✅ r1-3 fixed correctly — A single transient registry error during the 20-minute scan window aborts publication and forfeits the whole wait: Accepted-upload confirmation now retries transport failures, designated transient HTTP statuses, and interrupted metadata or tarball body reads within the existing monotonic deadline and lookup limit. The latest change prevents rejecting or indefinitely pending cancellation acknowledgements from overriding verification results or blocking polling.

Public-entry regressions cover a transient failur…

  • Open findings after this round: 0 (0 bug-severity).

No structured findings from the successful lane(s).

Workflow run

@FlyOverCoderKY
FlyOverCoderKY merged commit 0ff3b5f into main Nov 11, 2026
5 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.

1 participant