Skip to content

Commit

Permalink
Switch from using custom HTTP client caching to make-fetch-happen.
Browse files Browse the repository at this point in the history
This is a similar treatment as to what was applied to `@apollo/gateway` in
#3783.

This replaces a local HTTP cache implementation which continues to grow in
complexity with an off-the-shelf Fetch API client with many valuable bells
and whistles.  In particular, it uses `make-fetch-happen`, which is a
relatively full-featured Node.js based implementation which is used by `npm`
itself and leverages `minipass-fetch` under the hood.

This leverages the same cache implementation used in `@apollo/gateway` and
duplicates that cache logic.   It's entirely possible we would be
well-served to use the `cache.js` example that's included in the source of
`make-fetch-happen` and leverages `cacache`, but as of this message, it
doesn't include the TypeScript types and this implementation seems to work.

This does remove a test which was previously valuable but should no longer
be necessary.  Specifically, sine we now have an HTTP implementation that
handles caching and retries itself, we do handle intermediary retries within
that layer.  We still test the polling (i.e, the literal existence of an
interval which re-fires) in other tests, but it was too tricky to try to
re-jigger this test with the abstraction.  I think this is a good thing to
not need to worry about, but we can consider re-adding it in the event of
regressions.

Ref: https://npm.im/make-fetch-happen
Ref: https://npm.im/minipass-fetch
Ref: https://npm.im/cacache
Ref: https://github.com/npm/make-fetch-happen/blob/b04c4c16/cache.js
  • Loading branch information
abernix committed Jun 29, 2020
1 parent f3fbe15 commit 3bb9ef4
Show file tree
Hide file tree
Showing 7 changed files with 434 additions and 91 deletions.
Loading

0 comments on commit 3bb9ef4

Please sign in to comment.