From fb0449f2df6e2a8b140d3fae71066753289410a7 Mon Sep 17 00:00:00 2001 From: ruv Date: Fri, 6 Nov 2026 12:24:58 -0500 Subject: [PATCH] ci(stable-npm-release): wait for npm processing before the integrity check Runs 36345167527 (3.47.0) and 36445956751 (3.47.1) uploaded all three archives, then failed "does not match the verified archive integrity" after ~30 s of polling. The registry had not finished processing the uploads: the packument records 3.47.0 about 5 minutes and 3.47.1 about 14 minutes after `npm publish` returned, and both carry exactly the verified integrity. Because the step failed, dist-tags were never moved and the release-3-47-0 / release-3-47-1 candidate tags are still set. - Read version and integrity straight from registry.npmjs.org with Cache-Control: no-cache instead of `npm view`, polling with backoff for up to 30 minutes (the 10-minute loop on main is still shorter than the 14 minutes observed for 3.47.1). - Keep failing immediately on a readable, different integrity. - Make reruns safe: the "already published" probe is uncached, and a publish refused as previously published falls through to the wait. - Verify dist-tags from the uncached dist-tags endpoint for up to 5 min. - Raise the job timeout from 30 to 75 minutes to fit the wait. Co-Authored-By: claude-flow --- .github/workflows/stable-npm-release.yml | 66 ++++++++++++++++++------ 1 file changed, 49 insertions(+), 17 deletions(-) diff --git a/.github/workflows/stable-npm-release.yml b/.github/workflows/stable-npm-release.yml index 19eb62030b..e1a99fe57b 100644 --- a/.github/workflows/stable-npm-release.yml +++ b/.github/workflows/stable-npm-release.yml @@ -20,7 +20,7 @@ jobs: name: Publish stable package train if: github.actor == 'ruvnet' runs-on: ubuntu-latest - timeout-minutes: 30 + timeout-minutes: 75 steps: - name: Validate release inputs @@ -385,13 +385,35 @@ jobs: test "${#archives[@]}" -eq 3 test "${#integrities[@]}" -eq 3 + # Read one field of a published version straight from the registry, + # bypassing npm's local cache and the CDN. Prints nothing and fails + # when the version is not readable yet. + registry_field() { + curl -fsS --max-time 30 -H 'Cache-Control: no-cache' -H 'Accept: application/json' \ + "https://registry.npmjs.org/${1/\//%2f}/$2" 2>/dev/null | + FIELD="$3" node -e ' + let s = ""; process.stdin.on("data", (d) => (s += d)).on("end", () => { + let v; try { v = process.env.FIELD.split(".").reduce((o, k) => o?.[k], JSON.parse(s)); } catch {} + if (typeof v !== "string" || !v) process.exit(1); + process.stdout.write(v); + });' + } + for index in "${!packages[@]}"; do package="${packages[$index]}" archive="${archives[$index]}" - if npm view "${package}@${version}" version >/dev/null 2>&1; then + if registry_field "$package" "$version" version >/dev/null; then echo "${package}@${version} already published" - else - npm publish "$archive" --ignore-scripts --access public --tag "$candidate_tag" + elif ! npm publish "$archive" --ignore-scripts --access public --tag "$candidate_tag" 2>"$RUNNER_TEMP/publish.err"; then + cat "$RUNNER_TEMP/publish.err" >&2 + # A rerun can start while the first upload is still being processed: + # the version is not readable yet but the registry refuses it. + # Fall through to the integrity wait instead of failing here. + if grep -qE 'EPUBLISHCONFLICT|previously published|cannot publish over' "$RUNNER_TEMP/publish.err"; then + echo "${package}@${version} was already uploaded; waiting for registry processing" + else + exit 1 + fi fi done @@ -399,25 +421,32 @@ jobs: package="${packages[$index]}" expected_integrity="${integrities[$index]}" found=false - # npm can acknowledge an upload before its asynchronous processing - # makes the version readable. Do not republish or promote it early. - for attempt in {1..120}; do - registry_version="$(npm view "${package}@${version}" version 2>/dev/null || true)" - registry_integrity="$(npm view "${package}@${version}" dist.integrity 2>/dev/null || true)" - if [[ "$registry_version" == "$version" && "$registry_integrity" == "$expected_integrity" ]]; then + # npm acknowledges an upload before its asynchronous processing makes + # the version readable. 3.47.0 took about 5 minutes and 3.47.1 about + # 14 (runs 36345167527 and 36445956751 gave up after 30 seconds). + # Poll the registry directly for up to 30 minutes. Do not republish + # or promote the version early. + deadline=$((SECONDS + 1800)) + delay=5 + while (( SECONDS < deadline )); do + registry_integrity="$(registry_field "$package" "$version" dist.integrity || true)" + if [[ "$registry_integrity" == "$expected_integrity" ]]; then found=true break fi - if [[ -n "$registry_integrity" && "$registry_integrity" != "$expected_integrity" ]]; then - echo "::error::${package}@${version} has a different archive integrity" + if [[ -n "$registry_integrity" ]]; then + echo "::error::${package}@${version} has a different archive integrity: registry ${registry_integrity}, verified ${expected_integrity}" exit 1 fi - sleep 5 + echo "${package}@${version} not readable yet (${SECONDS}s); retrying in ${delay}s" + sleep "$delay" + delay=$(( delay < 30 ? delay * 2 : 30 )) done if [[ "$found" != true ]]; then - echo "::error::${package}@${version} was not available with the verified integrity within 10 minutes; inspect registry processing before retrying publication" + echo "::error::${package}@${version} was not available with the verified integrity within 30 minutes; inspect registry processing, then re-run this workflow (versions that are already published are skipped)" fi test "$found" = true + echo "${package}@${version} verified at ${expected_integrity}" done for package in "${packages[@]}"; do @@ -436,8 +465,11 @@ jobs: packages=("@claude-flow/cli" "claude-flow" "ruflo") for package in "${packages[@]}"; do tags_ready=false - for attempt in {1..10}; do - tags="$(npm view "$package" dist-tags --json 2>/dev/null || true)" + # Read dist-tags uncached; npm view can return a stale packument + # for minutes after `npm dist-tag add`. + for attempt in {1..60}; do + tags="$(curl -fsS --max-time 30 -H 'Cache-Control: no-cache' \ + "https://registry.npmjs.org/-/package/${package/\//%2f}/dist-tags" 2>/dev/null || true)" if TAGS="$tags" VERSION="$version" node - <<'NODE' const tags = JSON.parse(process.env.TAGS || '{}'); process.exit(['latest', 'alpha', 'v3alpha'].every((tag) => tags[tag] === process.env.VERSION) ? 0 : 1); @@ -446,7 +478,7 @@ jobs: tags_ready=true break fi - sleep 3 + sleep 5 done test "$tags_ready" = true TAGS="$tags" VERSION="$version" PACKAGE="$package" node - <<'NODE'