From c44d9ae16f10b007ade240052b2d2f253e3f1656 Mon Sep 17 00:00:00 2001 From: Benjamin Gruenbaum Date: Sun, 13 Feb 2022 18:24:34 +0200 Subject: [PATCH] fixup! cr --- lib/internal/modules/esm/fetch_module.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/internal/modules/esm/fetch_module.js b/lib/internal/modules/esm/fetch_module.js index ae0312ad7b36fc..20ab9c4774d760 100644 --- a/lib/internal/modules/esm/fetch_module.js +++ b/lib/internal/modules/esm/fetch_module.js @@ -30,6 +30,9 @@ const { compose } = require('stream'); /** * Only for GET requests, other requests would need new Map * HTTP cache semantics keep diff caches + * + * It caches either the promise or the cahce entry since import.meta.url needs + * the value synchronously for the response location after all redirects. * * Maps HREF to pending cache entry * @type {Map | CacheEntry>} @@ -101,6 +104,8 @@ function fetchWithRedirects(parsed) { const req = handler(parsed, { headers: { Accept: '*/*' }, }); + // Note that `once` is used here to handle `error` and that it hits the + // finally on network error/timeout. const { 0: res } = await once(req, 'response'); try { const isRedirect = res.statusCode >= 300 && res.statusCode <= 303;