Invalid location type passed to LoggingEvent constructor
matheustoseto opened this issue · comments
*I used the google translator
Hello, when using log4js version 6.9.1 in a nextjs 13 project, I am getting the following error:
"Invalid location type passed to LoggingEvent constructor"
I performed the debugging of the lib code and ended up finding the reason for the problem. Apparently the "stackReg"
of the file "./lib/logger.js"
does not interpret the following "stack" of nextjs, causing a null return.
I verified that version 6.7.1 meets my scenario and I ended up downgrading the version, but I decided to open this issue to document the problem.
Test Scenario
const stackReg_691 = /^(?:\s*)at (?:(.+) \()?(?:([^(]+?):(\d+):(\d+))\)?$/;
const stackReg_671 = /at (?:(.+)\s+\()?(?:(.+?):(\d+)(?::(\d+))?|([^)]+))\)?/;
const stackTrace = ' at RootLayout (webpack-internal:///(sc_server)/./app/layout.tsx:44:81)';
console.log(stackReg_691.exec(stackTrace));
console.log(stackReg_671.exec(stackTrace));
//result
null
[
'at RootLayout (webpack-internal:///(sc_server)/./app/layout.tsx:44:81)',
'RootLayout',
'webpack-internal:///(sc_server)/./app/layout.tsx',
'44',
'81',
undefined
]
Evidence
Logs by https://github.com/log4js-node/log4js-node/blob/master/lib/logger.js#LL26C16-L26C16
Self note: Maybe the following regex will be better
/^(?:\s*)at (?:(.+) \()?(?:(.+?):(\d+):(\d+))\)?$/
@matheustoseto, it might also be because of the additional (
brackets in the path.
const stackTrace = ' at RootLayout (webpack-internal:///(sc_server)/./app/layout.tsx:44:81)';
webpack-internal:///
(
sc_server)/./app/layout.tsx
If it's urgent, is it possible to remove the brackets? It should work before a fix is released.
Hello @lamweili, it's not urgent, the project is not in production. About the square brackets, it is inserted by nextjs itself, I have no control over it =/
I saw that a correction will be released in the new version, thank you very much :)