From dfa02ee8bd451e88b1b17564734f28aeae9b0164 Mon Sep 17 00:00:00 2001 From: Matthew Pull Date: Wed, 10 Nov 2021 00:54:16 +0000 Subject: [PATCH 1/2] Prevent "TypeError: Error.captureStackTrace is not a function" issue on non-Chromium browsers --- src/fetch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fetch.ts b/src/fetch.ts index cdf6502..998d6df 100644 --- a/src/fetch.ts +++ b/src/fetch.ts @@ -61,7 +61,7 @@ export function createFetch ({ fetch }: CreateFetchOptions): $Fetch { // Throw normalized error const err = createFetchError(request, error, response) - Error.captureStackTrace(err, $fetchRaw) + if (Error.captureStackTrace) Error.captureStackTrace(err, $fetchRaw) throw err } From 0be4199fca7c68d416081746782307354455995c Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 10 Nov 2021 13:01:55 +0100 Subject: [PATCH 2/2] add link --- src/fetch.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fetch.ts b/src/fetch.ts index 998d6df..e020a5a 100644 --- a/src/fetch.ts +++ b/src/fetch.ts @@ -61,7 +61,10 @@ export function createFetch ({ fetch }: CreateFetchOptions): $Fetch { // Throw normalized error const err = createFetchError(request, error, response) - if (Error.captureStackTrace) Error.captureStackTrace(err, $fetchRaw) + // Only available on V8 based runtimes (https://v8.dev/docs/stack-trace-api) + if (Error.captureStackTrace) { + Error.captureStackTrace(err, $fetchRaw) + } throw err }