Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid location type passed to LoggingEvent constructor #1388

Open
matheustoseto opened this issue Jun 15, 2023 · 4 comments · May be fixed by #1389
Open

Invalid location type passed to LoggingEvent constructor #1388

matheustoseto opened this issue Jun 15, 2023 · 4 comments · May be fixed by #1389
Labels
bug Something isn't working
Milestone

Comments

@matheustoseto
Copy link

matheustoseto commented Jun 15, 2023

*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

image

Logs by https://github.com/log4js-node/log4js-node/blob/master/lib/logger.js#LL26C16-L26C16

image
image

@lamweili
Copy link
Contributor

lamweili commented Jun 16, 2023

Self note: Maybe the following regex will be better
/^(?:\s*)at (?:(.+) \()?(?:(.+?):(\d+):(\d+))\)?$/

@lamweili lamweili added the bug Something isn't working label Jun 16, 2023
@lamweili lamweili added this to the 6.9.2 milestone Jun 16, 2023
@lamweili lamweili linked a pull request Jun 19, 2023 that will close this issue
@lamweili
Copy link
Contributor

@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.

lamweili added a commit that referenced this issue Jun 20, 2023
lamweili added a commit that referenced this issue Jun 20, 2023
lamweili added a commit that referenced this issue Jun 20, 2023
lamweili added a commit that referenced this issue Jun 20, 2023
lamweili added a commit that referenced this issue Jun 20, 2023
@matheustoseto
Copy link
Author

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 :)

@one-pieces
Copy link

@lamweili Hi, when the fix will be released? I get the same error in our project and can't get the logs in production. It's urgent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants