Skip to content

ci: publish waits for npm to serve what a package depends on - #254

Merged
alekswebnet merged 3 commits into
mainfrom
fix/publish-wait-for-npm
Nov 20, 2026
Merged

alekswebnet merged 3 commits into
mainfrom
fix/publish-wait-for-npm

Conversation

@alekswebnet

@alekswebnet alekswebnet commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #253.

Release 1.7.0 took four runs of publish.yml. npm takes a version in and processes it before it serves it, and each check that a dependency is on npm failed on one published moments before in the same run. npm held most packages for 1 to 4 minutes, and the 31 MB library pack for 14 (the table is in #253). mcp and verify had no check at all, so mcp 0.3.0 went out while the author 0.14.0 it needs was still being processed.

What changes

  • scripts/published.mjs is new.
    • served(url, label) asks again every 30 s while the answer is a 404, a server error, or a request that failed, timed out or could not be read. It reads a success's JSON body inside that loop, so a body cut or stalled after the headers is asked again too. A request, its body included, is cut at 30 s: one to npm hung for over 5 minutes while this was being written.
    • The wait belongs to the script, not to each request. waitUntil() takes H5P_PUBLISH_WAIT minutes once, every check in the script shares them, and when they run out served() returns the last answer.
    • stopUnlessAnswered() stops a check whose request failed with anything but a 404. Only a 404 says a version is not served, so the check says it could not be checked, not to publish what may already be there.
    • Run from a package's folder, it checks every dependency the package names by workspace:, at the version the workspace has. dependencies, optionalDependencies and peerDependencies count; devDependencies do not.
  • prepublishOnly: verify, embed, author and mcp run it right after the pnpm guard. mcp now checks author and verify, and verify checks the player and the runtime.
  • The three pin checks ask through served(): the player's pack check, embed's player and normalizer check, and the author's pack, player and normalizer check. That covers both npm and jsDelivr. Each script shares one wait and stops through stopUnlessAnswered(). The author's now says when jsDelivr has no parts/index.json, as the player's does. Their other checks are unchanged: the index matches this checkout's, and ./plan and ./crc32 are exported.
  • publish.yml sets H5P_PUBLISH_WAIT to 30, twice the longest seen. A dry run sets 0: it publishes nothing, so a dependency it would publish never appears, and the check stops at once, as before. By hand it is 0 too, so a dependency npm does not serve is reported at once, whether it was never published or is still being processed.
  • Docs: design/build.md has the rule and the numbers, and design/layout.md names the root scripts/. The trusted-publishing paragraph in design/build.md gets back its last two sentences, which the new paragraph had split off.

Tested

  • packages/author/tests/published.test.ts (9 tests):
    • it asks again after a 404, a 503 and a failed request, until a 200;
    • with no wait, it asks once;
    • a 403 is an answer, not a wait;
    • H5P_PUBLISH_WAIT sets the wait, and the wait runs out;
    • a request with no answer is cut and asked again;
    • a success whose body cannot be read is asked again;
    • a check goes on after a success or a 404, and stops on a 403, a 503, a DNS failure or a timeout without saying to publish;
    • dependencies share one wait: one that is missing leaves the next no wait of its own;
    • only workspace: dependencies that are not dev ones are asked for, at the workspace's versions;
    • for mcp, those are the author and the verifier at their versions here.
  • Type check: pnpm typecheck passes in the author, player, embed, mcp and verify packages. The author's covers the new script, which its tests import.
  • Against npm as it is now: each package's dependency check passes (mcp 2, verify 2, embed 4, author 3), and so do the three pin checks.
  • A dependency missing by hand: a test folder naming h5p-author 99.0.0 fails in 0.65 s with "is not on npm (404). Publish it first".
  • Failures, with fetch stubbed: each check exits 1 and says what happened. A DNS failure gives "could not be checked (ENOTFOUND) … run the publish again" in all four scripts. A success whose body is cut gives "could not be checked (terminated)". A jsDelivr 404 gives "has no parts/index.json, unlike this checkout" in both pack checks.

Summary by cubic

Fixes release 1.7.0's four failed runs of publish.yml (#253). npm processes a new version before it serves it — most packages took 1 to 4 minutes, the 31 MB library pack 14 — so each check that a dependency published moments earlier was on npm failed. mcp and verify had no check at all, and mcp 0.3.0 went out while the author version it needed was still being processed.

  • New scripts/published.mjs runs in the prepublishOnly of verify, embed, author, and mcp, checking every workspace: dependency at the workspace's version.
  • served() retries every 30 s while the answer is a 404, a server error, or a failed or timed-out request, and reads a success's body inside the loop so a cut body is retried too. All checks in a script share one wait of H5P_PUBLISH_WAIT minutes; each request is cut at 30 s.
  • publish.yml sets the wait to 30; by hand and in a dry run it is 0, so a 404 is reported at once.
  • The three pin checks (player's pack, embed's player and normalizer, author's pack/player/normalizer) wait the same way, for npm and jsDelivr. A failure other than a 404 stops a check with "could not be checked", never "publish it first".

Written for commit 6be200f. Summary will update on new commits.

View guided diff Turn on auto-fix

npm processes a new version before it serves it: 1 to 4 minutes for most
packages and 14 for the 31 MB pack in release 1.7.0, which took four runs.
scripts/published.mjs asks again every 30 s for up to H5P_PUBLISH_WAIT
minutes, which publish.yml sets to 30 (0 by hand and in a dry run). It runs
in the prepublishOnly of every package that names another by workspace:
(verify, embed, author, mcp), and the three pin checks use it. A request is
cut at 30 s.
Comment thread scripts/published.mjs Fixed

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 12 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread scripts/published.mjs Resolved
Comment thread scripts/published.mjs Resolved
Comment thread design/layout.md Resolved
Comment thread design/build.md Resolved
Comment thread design/build.md Resolved
…issing version (#253)

From the review of #254:
- served() reads a success's JSON body inside its retry loop, so a body
  cut or stalled after the headers is asked again instead of thrown;
- waitUntil() takes H5P_PUBLISH_WAIT once per script and every check in
  it shares that wait, which was each request's;
- stopUnlessAnswered() stops a check on any failure but a 404 with
  "could not be checked", where a DNS failure or a timeout said "not on
  npm, publish it first";
- the author's pack check says when jsDelivr has no parts/index.json, as
  the player's does;
- the npm URL escapes every "/" (CodeQL);
- the docs name only non-dev workspace dependencies, say a 404 by hand
  may be a version still being processed, and give the trusted-publishing
  paragraph back its last two sentences, which the new one had split off.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 8 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/author/tests/published.test.ts Resolved
Comment thread design/build.md Resolved
Comment thread design/build.md Resolved
…nd for jsDelivr (#253)

From the second review of #254:
- the test that dependencies share one wait moved a 30 ms real-time
  window, which a busy runner could miss; its requests now move a clock
  of their own, so the wait runs out at the fourth request every time;
- design/build.md says what a 404 means from npm and from jsDelivr, and
  what the check prints after any other failure.
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.

Publishing: wait for npm to serve a dependency published earlier in the same run

2 participants