Skip to content

Maintenance: gate publish_layer on npm registry availability to avoid ETARGET race during release #5564

Description

@svozza

Summary

The publish_layer job in make-release can fail because it starts installing the just-published packages from npm before the registry actually serves them. needs: publish-npm guarantees that npm publish returned — not that registry.npmjs.org resolves the new versions. The layer's CDK bundling does a real npm i @aws-lambda-powertools/<pkg>@<version>, so it is fully exposed to registry propagation delay.

This broke the v2.35.0 release (run 32124487679). publish_layer / build-layer failed in the CDK build step and blocked every downstream job — beta and prod layer deploys, GovCloud, China, the SSM update, and the layer ARN docs PR:

npm error code ETARGET
npm error notarget No matching version found for @aws-lambda-powertools/commons@2.35.0.
«FailedToBundleAsset» Failed to bundle asset LayerPublisherStack/LambdaPowertoolsLayer/Code/Stage

Why is this needed?

A release that publishes cleanly to npm can still leave the layers unpublished and the docs un-updated, requiring manual intervention to notice and re-run. The failure is also misleading: ETARGET reads as "we asked for a version that doesn't exist", i.e. a bug in our own version wiring, rather than "the registry hasn't caught up yet".

Timeline for v2.35.0 (UTC, comparing the publish job log against each package's time.<version> field in its packument):

event time
npm publish prints + @aws-lambda-powertools/commons@2.35.0 10:20:09
npm publish prints + @aws-lambda-powertools/logger@2.35.0 10:20:16
last package published, publish-npm job succeeds 10:21:01
build-layer starts npm i ...@2.35.0 10:21:58
npm i fails with ETARGET on commons@2.35.0 10:22:04
commons@2.35.0 becomes resolvable on the registry 10:22:14
logger@2.35.0 becomes resolvable on the registry 10:27:23

commons missed by 10 seconds. logger took 7m07s after its publish call returned. Twelve of the fourteen packages propagated within ~1s, so this is intermittent and unpredictable — a fixed sleep would not reliably cover it.

Worth recording for whoever hits this next: during the lag window the version 404s on every registry endpoint (version doc, tarball, packument entry, npm view) while npm's attestations endpoint already serves the signed publish and SLSA provenance attestations for that exact version:

GET /-/npm/v1/attestations/@aws-lambda-powertools/logger@2.35.0   → 200
    subject: pkg:npm/@aws-lambda-powertools/logger@2.35.0
GET /@aws-lambda-powertools/logger/2.35.0                          → 404   (same moment)

That asymmetry looks exactly like npm dropped or partially wrote the publish, which makes republishing tempting. It isn't, and republishing over a version npm already holds a record for risks a 409 that would need npm support to unpick. The correct response is to wait, re-verify, and re-run.

Which area does this relate to?

Automation

Solution

Add a registry-availability gate so the release either waits or fails loudly with an accurate reason:

  1. Verify step at the end of publish-npm — for every non-private workspace, poll https://registry.npmjs.org/<pkg>/<version> until it returns 200 (and HEAD the dist.tarball URL), with a timeout of ~10 minutes given the 7-minute observation. This keeps the failure inside the job that owns publishing and gives an unambiguous message.
  2. Belt and braces in the layer build — retry the bundling npm i a few times with backoff, so a slow CDN edge doesn't take out a release that is otherwise fine.

Option 1 alone addresses the reported failure. Option 2 additionally covers the case where the packument is served but the tarball hasn't propagated.

Relevant code:

  • .github/workflows/make-release.ymlpublish_layer gated only on needs: publish-npm
  • .github/workflows/publish_layer.ymlbuild-layer / CDK build step
  • layers/src/layer-publisher-stack.ts — bundling shells out to npm i for the published versions

Workaround in the meantime: wait for the versions to appear, confirm with npm view <pkg>@<version> version, then gh run rerun <run-id> --failed.

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Metadata

Metadata

Assignees

No one assigned

    Labels

    internalPRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.)triageThis item has not been triaged by a maintainer, please wait

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions