From 56e5319e096f282a99cb008f3086f083dc782992 Mon Sep 17 00:00:00 2001 From: blaine-arcjet <146491715+blaine-arcjet@users.noreply.github.com> Date: Mon, 4 Nov 2024 14:02:18 -0700 Subject: [PATCH] fix(arcjet): Log error message when fingerprint cannot be built (#2139) Closes #2138 We can't `JSON.stringify` an error object, so this pulls the error message out of the object and assigns it to the `error` property on the logger props object. --- arcjet/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arcjet/index.ts b/arcjet/index.ts index c6107a924..98324a223 100644 --- a/arcjet/index.ts +++ b/arcjet/index.ts @@ -1309,15 +1309,19 @@ export default function arcjet< ); log.debug("fingerprint (%s): %s", rt, fingerprint); } catch (error) { + const errMsg = errorMessage(error); log.error( - { error }, + { + // Workaround for inability to JSON.stringify Error objects + error: errMsg, + }, "Failed to build fingerprint. Please verify your Characteristics.", ); const decision = new ArcjetErrorDecision({ ttl: 0, reason: new ArcjetErrorReason( - `Failed to build fingerprint - ${errorMessage(error)}`, + `Failed to build fingerprint - ${errMsg}`, ), // No results because we couldn't create a fingerprint results: [],