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.
This commit is contained in:
David Fiala 2024-03-27 16:39:45 -07:00 committed by GitHub
parent 6f5a955d8c
commit 2099f540d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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';
}
/**