Skip to content

#2517 only fetch plugin package info from NPM when needed#2518

Merged
36degrees merged 3 commits intoalphagov:mainfrom
RichardBradley:2517-fetch-npm-on-demand
Apr 7, 2026
Merged

#2517 only fetch plugin package info from NPM when needed#2518
36degrees merged 3 commits intoalphagov:mainfrom
RichardBradley:2517-fetch-npm-on-demand

Conversation

@RichardBradley
Copy link
Copy Markdown
Contributor

Fixes #2517

Changes

1; The "pluginVersionSatisfies " function, which is called a lot, doesn't need to make a network fetch to NPM, it can be satisfied from the local package.json data. (This does mean that it will return true for non-plugin packages, but I can't see why that would do any harm)

This saves some dev startup time (see deleted pluginCacheMiddleware)

2: The plugin cache can be made fetch-on-demand, instead of polling every 36 seconds.
I wonder if the 36 second config was a typo for 10 hours: 36000 millis vs 36000 seconds.
I have set the stale time to 1 minute, now that it's not polling all the time.
See deleted startPackageTracker

Testing

All unit tests pass
I have ran a new prototype locally and it starts ok and looks good to me.
The plugins page looks good to me.
The plugin data is fetched from NPM only when the plugins page is viewed.
The prototype will start with no internet (before it refused to even start).

Please let me know if you have any questions

@36degrees
Copy link
Copy Markdown
Contributor

Thanks for looking into this @RichardBradley. I'm hoping we'll have a chance to review this properly next week.

The 'Tests (Heroku)' failures are unrelated to the changes in this PR – the Heroku tests install the latest version of heroku using npx, and a new major version of Heroku has been released in the last couple of weeks which has broken things. I'm trying to work out the best way to fix this to get the tests passing on main again.

The linting failures do look related to the changes – do you have capacity to address them? Hopefully standard --fix should take care of them.

@RichardBradley
Copy link
Copy Markdown
Contributor Author

Thanks

I have run standard and pushed a new version

@36degrees
Copy link
Copy Markdown
Contributor

@RichardBradley thanks for doing that!

The Heroku tests are now passing on main, but this branch will need rebasing to get them passing here too.

Would you be happy to do that? I can do it for you if you prefer, but you'll need to remember to sync your local branch up if you make any further changes.

@RichardBradley RichardBradley force-pushed the 2517-fetch-npm-on-demand branch from 1b4d419 to 2e6fcba Compare March 30, 2026 13:27
@RichardBradley
Copy link
Copy Markdown
Contributor Author

Sure, I have rebased against current main.

I'm happy for you to rebase if needed again

Copy link
Copy Markdown
Member

@romaricpascal romaricpascal left a comment

Choose a reason for hiding this comment

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

That's brilliant @RichardBradley, thanks for fixing this and apologies for missing that the way we originally implemented it meant regular hits to npm over the network. 🙌🏻

This'll need a second review from @alphagov/design-system-developers before we can merge it, but looks all good to me 😊

Copy link
Copy Markdown
Contributor

@domoscargin domoscargin left a comment

Choose a reason for hiding this comment

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

Nice, thanks!

@36degrees 36degrees force-pushed the 2517-fetch-npm-on-demand branch from 2e6fcba to adafbd8 Compare April 7, 2026 11:05
@36degrees
Copy link
Copy Markdown
Contributor

I've rebased against main and added a commit to add this to the changelog (required a force-push because of the rebase)

@36degrees 36degrees merged commit 59d0da3 into alphagov:main Apr 7, 2026
52 of 54 checks passed
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.

proto kit unusable with slow or no internet: "Failed to load the package cache"

4 participants