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

fix(datasource/npm): respect abortOnError hostRule for registries #26196

Merged
merged 4 commits into from
Mar 23, 2024

Conversation

Shegox
Copy link
Contributor

@Shegox Shegox commented Dec 8, 2023

Changes

This PR adjusts the npm datasource to respect hostRules with abortOnError.
This is archived through checking if the http request throws an ExternalHostError and if yes will throw them up.

To keep the existing logic of aborting on registry.npmjs.com it checks if a hostRule with an explicit abortOnError setting exists and only if not we will add a custom hostRule setting abortOnError: true for registry.npmjs.com. This allows as well to explicitly opt-out of abortOnError for registry.npmjs.com with abortOnError: false.

Context

Fixes #13482

Additionally it allows to set abortOnError for custom registries, which is a use-case I currently have.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository
    • testing unavailable custom host with abortOnError: true => aborts run
    • testing unavailable custom host without abortOnError => doesn't abort run
    • testing unavailable registry.npmjs.org without abortOnError => aborts run
    • testing unavailable registry.npmjs.org with abortOnError: false => doesn't abort run

@rarkins rarkins requested a review from zharinov December 8, 2023 10:55
Copy link
Collaborator

@rarkins rarkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zharinov is this change complementary to the refactoring you plan to do?

@zharinov
Copy link
Collaborator

Looks so

@rarkins rarkins requested a review from viceice March 19, 2024 06:07
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise LGTM

lib/modules/datasource/npm/get.ts Outdated Show resolved Hide resolved
@Shegox Shegox requested a review from viceice March 23, 2024 12:28
@rarkins rarkins enabled auto-merge March 23, 2024 12:45
@rarkins rarkins added this pull request to the merge queue Mar 23, 2024
Merged via the queue into renovatebot:main with commit 0445d3f Mar 23, 2024
37 checks passed
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 37.267.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Shegox Shegox deleted the abort-npm branch March 25, 2024 09:47
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

abortOnError:false not working
5 participants