Bug: [BUG] Cannot read properties of undefined (reading 'map') at prettyFormatErrorObj
#311
Labels
bug
Something isn't working
Describe the bug
a undefined not handle by
prettyFormatErrorObj
then call thegetErrorTrace
.Screenshots
![图片](https://private-user-images.githubusercontent.com/6566869/396415161-9c837b4d-d492-4707-9970-2019664ac8c9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyODkzMzYsIm5iZiI6MTczOTI4OTAzNiwicGF0aCI6Ii82NTY2ODY5LzM5NjQxNTE2MS05YzgzN2I0ZC1kNDkyLTQ3MDctOTk3MC0yMDE5NjY0YWM4YzkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTFUMTU1MDM2WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NGYwNTRjYjI1ZGUwN2ZmYzFlMzdkYWE5NGY2YmQ1MTkwMGVlN2ZlNjA2MzE4NzAyYzllYTJmODg5NWZlOGU1NyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.NJBzTP23yxEp2yN1v6vAwOYm8ZQ5V6mODwL7snTLmeY)
To Reproduce
this is a large project, so i checked into the code. and finded the bug.
the error throw from this line :
tslog/src/runtime/nodejs/index.ts
Line 129 in 9a5d156
it tell me
Cannot read properties of undefined (reading 'map') at prettyFormatErrorObj
.so , we can kwon that , the return of
getErrorTrace()
is undefined .when we see the function
getErrorTrace()
we can find that :tslog/src/runtime/nodejs/index.ts
Lines 64 to 71 in 9a5d156
the function
getErrorTrace()
is returnundefined | IStackFrame[]
notIStackFrame[]
.because the function use
?.
chain .and after i search all code , i find that the browser version code was fixed this issue.
tslog/src/runtime/browser/index.ts
Lines 64 to 72 in 9a5d156
it fix by a
?? []
simply .Expected behavior
simple write code like browser , then all will work.
the right code maybe like here :
Node.js Version
v20.12.2
OS incl. Version
win10
The text was updated successfully, but these errors were encountered: