From 0c55e1ec1bf21fcb3a7fc6ed570956b4dfba80d5 Mon Sep 17 00:00:00 2001 From: Matthew Pull Date: Wed, 10 Nov 2021 12:03:14 +0000 Subject: [PATCH] fix: add check for using `Error.captureStackTrace` (#27) Co-authored-by: Matthew Pull --- src/fetch.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fetch.ts b/src/fetch.ts index f09830c7..c3881d98 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) - 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 }