Skip to content

Commit

Permalink
Resolve exception when Error.stackTraceLimit is undefined
Browse files Browse the repository at this point in the history
Some applications may explicitly set Error.stackTraceLimit = undefined. In this case it is not safe to assume new Error().stack is available.
  • Loading branch information
davidfiala committed Mar 27, 2024
1 parent 6f5a955 commit 2099f54
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/grpc-js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export type ClientOptions = Partial<ChannelOptions> & {
};

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';
}

/**
Expand Down

0 comments on commit 2099f54

Please sign in to comment.