Skip to content

module: prefer async/await in https imports

cc @bmeck @nodejs/modules

This PR refactors the fetch_module fetchWithRedirects function to use the new modern facilities for streams:

  • compose instead of pipe for simplified and "more easily correct" error handling on the body stream cc @ronag .
  • async/await over new Promise.
  • toArray() on the response body instead of manually.

Note this can probably be further simplified by always caching the promise (and never the value) and by moving the "memoize" functionality to a helper).

Fixes: https://github.com/nodejs/node/pull/41950

Merge request reports

Loading