Bug: Stack trace parsing breaks with parentheses
Describe the bug TS Log fails to produce proper stack traces when file paths contain parenthesis. When it encounters the parentheses it doesn't expect, the resulting formatted error message has "error stack: " and an asterisk for every line of the trace, but no content.
Example:
2023-06-14 23:04:11.939 WARN Auth:Service
JWTExpired "exp" claim timestamp check failed
error stack:
•
•
•
•
•
To Reproduce Steps to reproduce the behavior:
- Create a file that has a path containing parenthesis
- Create an error from that file
- Log that error with a Logger instance
Expected behavior The error should display a proper stack trace
Screenshots If applicable, add screenshots to help explain your problem.
Additional context
The culprit seems to be here. This regex causes fullFilePath to be incomplete and the logic that follows eventually discards the line, resulting in incomplete error messages.
Node.js Version 16.17.0
TS Log Version 4.8.2
Upon further development, I'm just now noticing that when tslog executes in the browser context, it prints errors properly despite the parenthesis in the pathnames. So, now I'm more confused as to why it doesn't work from the node context.
I was able to create a workaround by changing the regex in the aforementioned stackLineToStackFrame function to /\((.+)\)/. Therefore, I think I have confirmed that the issue is indeed caused by the regex in the link from above.
Unfortunately, due to #241, implementing the simple workaround required re-creating approx 230 lines worth of extraneous functions and some shady imports directly from the node_modules folder to access unexposed types, thereby effectively disconnecting a significant portion of the code from the TsLog codebase and future updates. The workaround serves as a proof of concept, I guess, but I can't recommend it as a solution due to the significant portions of code that had to be localized and will inevitably become obsolete.
Does this problem still exist?
It works on my mac with V.4.8.7
It's not working with regular ones:
> [email protected] dev-ts
> nodemon example(s/nodejs/index2.ts
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `nodemon example(s/nodejs/index2.ts'
I'm still getting this with Next.js app router paths which may have parentheses. Please open the ticket again :-) v4.9.2