From b5522828a3bc812e7e83440b6d52257a131ce1d2 Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Tue, 29 Oct 2024 10:10:16 -0500 Subject: [PATCH] feat: Added a 404 status check (#2272) In cases of 404 status messages, an html content 404 page was getting saved to disk later showing a non-helpful error to consumers. This should make the problem more explicit. resolves #2271 --- packages/jsapi-nodejs/src/serverUtils.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/jsapi-nodejs/src/serverUtils.ts b/packages/jsapi-nodejs/src/serverUtils.ts index 8aae9c2bc3..f7c89fe1b9 100644 --- a/packages/jsapi-nodejs/src/serverUtils.ts +++ b/packages/jsapi-nodejs/src/serverUtils.ts @@ -45,6 +45,11 @@ export async function downloadFromURL( }); res.on('end', async () => { + if (res.statusCode === 404) { + reject(new Error(`File not found: "${url}"`)); + return; + } + resolve(file); }); })