lerna: lerna publish should handle retry 403s better

Expected Behavior

retries in lerna publish should gracefully handle 403 for the version that is being published. i.e. if lerna is trying to publish 3.4.5, gets a network hiccup, retries, and that retry fails due to 403, then lerna should only warn, not fail.

Current Behavior

instead, lerna treats 403s as a sign of failure, when, according to my understanding, a 403 on npm publish means that the intended version already exists. if this is a retry, then that’s a warning not a failure.

lerna http fetch PUT 200 http://registry.npmjs.org/@kui-shell%2fplugin-wskflow 11783ms
lerna http fetch PUT 403 http://registry.npmjs.org/@kui-shell%2fplugin-proxy-support 24971ms attempt #2
lerna ERR! E403 You cannot publish over the previously published versions: 3.0.29.

and then we are left with uncommitted changes, because lerna optimistically pushes updates to my repo, but then leaves some of the commit hashes uncommitted, because it gave up. ugh.

Possible Solution

lerna publish could remember that it is doing a retry, and only warn on 403s seen during retries.

Steps to Reproduce (for bugs)

this is an erratic condition, subject to network conditions and the status of npmjs

lerna.json

<!-- Please paste your `lerna.json` here -->

lerna-debug.log

<!-- If you have a `lerna-debug.log` available, please paste it here -->
<!-- Otherwise, feel free to delete this <details> block -->

Context

Your Environment

Executable Version
lerna --version 3.16.4
npm --version 6.9.0
yarn --version n/a
node --version v10.16.2
OS Version
NAME VERSION
macOS Sierra 10.14.6

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 10
  • Comments: 16 (2 by maintainers)

Most upvoted comments

Same issue here with lerna 3.19.0. Seems like package is published, but it’s marked as failed, then lerna tries to publish it again and fails.

Doubling down on the suggestion that these types of errors should be notices/warnings. This could even be configurable with a flag. Or even better make retry logic configurable

  • retryTimeout: number
  • retryAttempts: number
  • publishFailuresResultInError: boolean

@jmccann Thanks for pointing this out. I’m not sure why the output in the video shows an error, but I can confirm that Lerna will succeed and the command will finish. The output will look like this: image

This is with Lerna v6.5.1

I’m seeing this sporadically in my Github Actions and always wondered why it occurs. Thanks for the explanation and I hope your proposal will be picked up!