Skip to content

Commit ba9111f

Browse files
authored
fix(release): tolerate npm publish-time scanning before consumer verification (#693)
* fix(release): allow npm malware scanning to complete before consumer checks * test(release): cover npm post-publish scanning delay * docs(release): clarify npm scanning and safe retry * fix(types): preserve waitForRegistryAvailability JSDoc contract * test(release): avoid noisy output in simulated registry delay
1 parent 1f5c46d commit ba9111f

3 files changed

Lines changed: 38 additions & 7 deletions

File tree

‎docs/RELEASE.md‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,16 @@ and create GitHub Releases from the package changelogs. Ordinary merges never pu
2727
After Changesets reports a successful npm publish, the workflow **must** verify the
2828
exact versions are visible from the public registry before running the clean
2929
consumer install, published user journey, and golden path. Registry metadata can
30-
lag npm's publish acknowledgment: the visibility gate checks fresh npm metadata
31-
(with an isolated temporary cache for every probe) for up to approximately ten
32-
minutes. Only E404/ETARGET or a stale version response may be retried; unexpected
30+
lag npm's publish acknowledgment because npm scans newly published packages
31+
before they become installable (typically around five minutes, sometimes 15+
32+
minutes). The visibility gate checks fresh npm metadata (with an isolated
33+
temporary cache for every probe) for up to approximately **30 minutes**.
34+
Only E404/ETARGET or a stale version response may be retried; unexpected
3335
npm/authentication/network/parsing failures still fail immediately. A timeout
34-
fails the workflow without claiming the release was not published.
36+
fails the workflow without claiming the release was not published; check the
37+
exact package versions and their scan/review state in npmjs.com before
38+
retrying the original approved release PR. Do not bump the package versions
39+
or create a new release PR solely because npm visibility was delayed.
3540

3641
The gate also fetches the **exact tarball** named by that metadata and verifies
3742
its mandatory sha512 `dist.integrity` and complete gzip structure before installing (#628): npm can expose

‎scripts/npm-consumer-smoke.mjs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ export async function registryReleaseConsumable(spec, npm = 'npm', options = {})
202202
return tarballAvailable(spec, npm, options);
203203
}
204204

205+
/** npm publish-time malware scanning can delay public availability 15+ minutes. */
206+
export const REGISTRY_AVAILABILITY_MAX_ATTEMPTS = 180;
207+
205208
/**
206209
* @param {{packages: Array<{name: string, version: string, tarball?: string}>}} plan
207210
* @param {{
@@ -212,7 +215,7 @@ export async function registryReleaseConsumable(spec, npm = 'npm', options = {})
212215
*/
213216
export async function waitForRegistryAvailability(plan, {
214217
registryOnly = false,
215-
maxAttempts = 60,
218+
maxAttempts = REGISTRY_AVAILABILITY_MAX_ATTEMPTS,
216219
intervalMs = 10000,
217220
probe = registryReleaseConsumable,
218221
pause = sleep
@@ -229,7 +232,9 @@ export async function waitForRegistryAvailability(plan, {
229232
}
230233
if (missing.length === 0) return;
231234
if (attempt === maxAttempts) {
232-
throw new Error(`npm registry propagation timed out after ${maxAttempts} checks: ${missing.join(', ')}`);
235+
throw new Error(`npm registry propagation timed out after ${maxAttempts} checks: ${missing.join(', ')}. ` +
236+
'Changesets publishing may have succeeded while npm publish-time scanning is still pending, held for manual review, or blocked. ' +
237+
'Check each exact package version in npmjs.com Versions/Staged Packages and any maintainer notifications before retrying the same approved release; do not bump versions.');
233238
}
234239
console.log(`Waiting for npm registry propagation (check ${attempt}/${maxAttempts}): ${missing.join(', ')}`);
235240
await pause(intervalMs);

‎tests/npm-consumer-smoke.test.ts‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:
55
import { join } from 'node:path';
66
import { tmpdir } from 'node:os';
77

8-
const { consumerInstallSpecs, consumerSource, consumerTsConfig, packageTypePath, validateInstalledTypes, waitForRegistryAvailability, registryVersionVisible, tarballAvailable, registryReleaseConsumable } = await import('../scripts/npm-consumer-smoke.mjs');
8+
const { consumerInstallSpecs, consumerSource, consumerTsConfig, packageTypePath, validateInstalledTypes, waitForRegistryAvailability, REGISTRY_AVAILABILITY_MAX_ATTEMPTS, registryVersionVisible, tarballAvailable, registryReleaseConsumable } = await import('../scripts/npm-consumer-smoke.mjs');
99

1010
describe('npm consumer smoke test (#330)', () => {
1111
it('resolves the declared type entry for every exact package', () => {
@@ -108,6 +108,27 @@ describe('npm consumer smoke test (#330)', () => {
108108
expect(waits).toBe(2);
109109
});
110110

111+
it('allows npm publish-time scanning beyond the former ten-minute window without real delays', async () => {
112+
// npm scans accepted publications before they become installable. The
113+
// registry can return E404 for 15+ minutes even after Changesets succeeds.
114+
expect(REGISTRY_AVAILABILITY_MAX_ATTEMPTS).toBe(180);
115+
let attempts = 0;
116+
let pauses = 0;
117+
const log = vi.spyOn(console, 'log').mockImplementation(() => {});
118+
try {
119+
await expect(waitForRegistryAvailability({
120+
packages: [{ name: 'svforge', version: '5.0.1' }]
121+
}, {
122+
probe: () => { attempts++; return false; },
123+
pause: async () => { pauses++; }
124+
})).rejects.toThrow(/Check each exact package version in npmjs\.com Versions\/Staged Packages/);
125+
expect(attempts).toBe(180);
126+
expect(pauses).toBe(179);
127+
} finally {
128+
log.mockRestore();
129+
}
130+
});
131+
111132
it('never retries an unavailable registry or network failure', async () => {
112133
// The registry being DOWN (DNS refusal, connection refused, timeout) is
113134
// not propagation in flight: fail immediately with the real cause instead

0 commit comments

Comments
 (0)