Skip to content

Commit

Permalink
fix(arcjet): Log error message when fingerprint cannot be built (#2139)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
blaine-arcjet authored Nov 4, 2024
1 parent 73d94d5 commit 56e5319
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions arcjet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down

0 comments on commit 56e5319

Please sign in to comment.