From 68f58bf63552181a7a24d005eba22ca2fc0bb36c Mon Sep 17 00:00:00 2001 From: Francesco Guardiani Date: Wed, 10 Jan 2024 18:29:16 +0100 Subject: [PATCH] Remove cause from TerminalError, as it's not supported by the protocol (#224) --- src/restate_context_impl.ts | 1 - src/types/errors.ts | 2 +- src/utils/utils.ts | 6 +++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/restate_context_impl.ts b/src/restate_context_impl.ts index cbf2c56f..fb9f3420 100644 --- a/src/restate_context_impl.ts +++ b/src/restate_context_impl.ts @@ -471,7 +471,6 @@ async function executeWithRetries( `Retries exhausted for ${name}. Last error: ${error.name}: ${error.message}`, { errorCode: ErrorCodes.INTERNAL, - cause: error, } ); } diff --git a/src/types/errors.ts b/src/types/errors.ts index 3fcbeb62..2b3dcc31 100644 --- a/src/types/errors.ts +++ b/src/types/errors.ts @@ -197,7 +197,7 @@ export class RestateError extends Error { // Does not lead to Restate retries // Leads to an output message with a failure defined export class TerminalError extends RestateError { - constructor(message: string, options?: { errorCode?: number; cause?: any }) { + constructor(message: string, options?: { errorCode?: number }) { super(message, options); } } diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 3e2a7c28..13ddb1b5 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -72,7 +72,11 @@ export function jsonDeserialize(json: string): T { // When using google.protobuf.Value in RPC handler responses, we want to roughly match the behaviour of JSON.stringify // for example in converting Date objects to a UTC string export function jsonSafeAny(key: string, value: any): any { - if (value !== undefined && value !== null && typeof value.toJSON == "function") { + if ( + value !== undefined && + value !== null && + typeof value.toJSON == "function" + ) { return value.toJSON(key) as any; } else if (globalThis.Array.isArray(value)) { // in place replace