From 213230c73b9300ae9fff6b8f2e66f9913439dde7 Mon Sep 17 00:00:00 2001 From: David Fiala Date: Wed, 27 Mar 2024 16:39:45 -0700 Subject: [PATCH] Resolve exception when Error.stackTraceLimit is undefined Some applications may explicitly set Error.stackTraceLimit = undefined. In this case it is not safe to assume new Error().stack is available. --- packages/grpc-js/src/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/grpc-js/src/client.ts b/packages/grpc-js/src/client.ts index e122f6cf4..995d5b328 100644 --- a/packages/grpc-js/src/client.ts +++ b/packages/grpc-js/src/client.ts @@ -110,7 +110,7 @@ export type ClientOptions = Partial & { }; function getErrorStackString(error: Error): string { - return error.stack!.split('\n').slice(1).join('\n'); + return error.stack?.split('\n').slice(1).join('\n') || 'no stack trace available'; } /**