Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable throttling when publishing modules #4013

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Ayowel
Copy link

@Ayowel Ayowel commented May 27, 2024

The aim is to provide a way to fix #3962 .

This is opened to validate the implementation design and get feedback on the specific values that should be used as defaults.

Currently known limits when uploading to NPM:

  • Burst limit of 25/500 modules per 24h (depending on account/already-published modules)

Description

Add three publishing options:

  • --throttle to enable/disable throttling
  • --throttle-size: the 'bucket size' to use when throttling
  • --throttle-delay: Once the bucket is full, the minimum time between the end of a module upload and the start of an other module's upload

Throttling is enabled by default when publishing to NPM. The throttling implementation is designed to allow changes in the implementation/maintaining different implementations without too much trouble

Motivation and Context

See #3962: NPM throttles module publishing, which results in partial publish which are a pain to deal with

How Has This Been Tested?

Tested on ubuntu with node 20.9.0:

  • With the new testfile libs/commands/publish/src/lib/throttle-queue.spec.ts
  • By publishing to a local verdaccio instance

The removal from draft of this PR will wait for the upload to NPM of a 10000+ modules monorepo

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@JamesHenry
Copy link
Member

@Ayowel this comment wasn't entirely clear to me:

The removal from draft of this PR will wait for the upload to NPM of a 10000+ modules monorepo

Are you going to be reporting back to us once you have done this? Is that repo in question a real thing? Or something built just to test this functionality?

I have pulled in the latest main so that you can get initial CI feedback

@JamesHenry
Copy link
Member

It failed code formatting, you can run npm run format:write and commit the result

@Ayowel
Copy link
Author

Ayowel commented Jun 8, 2024

Are you going to be reporting back to us once you have done this? Is that repo in question a real thing? Or something built just to test this functionality?

The repo is a real thing, I'm having trouble with the specifics of lerna's configuration as some configuration works when testing locally on a small repo but not when pushing with the actual repository.

It appears that the NPM limit is not fixed (I was at 25 publish per day before getting timed-out initially, I'm allowed ~500/day at the moment and I'm not clear why the limit changed), so I'll move throttling to an off-by-default state to honor the principle of least astonishment (and enabling throttling will be the user's responsibility).

I'll rebase, format, and push once I figure this out

@Ayowel
Copy link
Author

Ayowel commented Jun 16, 2024

@JamesHenry Looks good to me, removing draft status.
To whom it may interest, the throttling configuration I'm using at the moment to publish to NPM is the following (keep in mind that my current limit is 500/day, not the 25 that an account that has not published module might have):

{
  "command": {
    "publish": {
      "throttle": true,
      "throttleDelay": 7200,
      "throttleSize": 40
    }
  }
}

@Ayowel Ayowel marked this pull request as ready for review June 16, 2024 12:50
@Ayowel
Copy link
Author

Ayowel commented Jun 21, 2024

Not sure if I should keep rebasing each time master is updated, let me know if i shouldn't

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.

Support publish throttling
2 participants