fullstack-build / tslog

📝 tslog - Universal Logger for TypeScript and JavaScript
https://tslog.js.org
MIT License
1.33k stars 63 forks source link

Bug: [BUG] Suspected bug in infinite loop avoidance logic #139

Closed cspotcode closed 1 year ago

cspotcode commented 2 years ago

Describe the bug

Someone reported this bug a while back: https://github.com/cspotcode/node-source-map-support/issues/36

I see that tslog has logic to avoid infinite loops. This suggests to me that the logic might be failing in certain situations.

https://github.com/fullstack-build/tslog/blob/3b47ff2036a6e4b05eb07a64d8d0d9b7d7f48bd9/src/CallSitesHelper.ts#L42-L49

To Reproduce Steps to reproduce the behavior:

Ping @GhaithZamrik for a proper reproduction, and for all of the following details.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

Node.js Version

OS incl. Version

Windows; @GhaithZamrik says it only happens on windows.

GhaithZamrik commented 2 years ago

I can't say what are the reproducible steps per se as there's nothing special about the project. If I am able to create a simpler version that causes the same issue I'll post it here. It's a TS NextJS project.

The information that I have at the moment are the following:

Error: C:\Users\user\repo\node_modules\@cspotcode\source-map-support\source-map-support.js:227 while (match = re.exec(fileData)) lastMatch = match; ^ RangeError: Maximum call stack size exceeded at RegExp.exec (<anonymous>) at retrieveSourceMapURL (C:\Users\user\repo\node_modules\@cspotcode\source-map-support\source-map-support.js:227:21) at Array.<anonymous> (C:\Users\user\repo\node_modules\@cspotcode\source-map-support\source-map-support.js:239:26) at C:\Users\user\repo\node_modules\@cspotcode\source-map-support\source-map-support.js:138:32 at mapSourcePosition (C:\Users\user\repo\node_modules\@cspotcode\source-map-support\source-map-support.js:269:21) at wrapCallSite (C:\Users\user\repo\node_modules\@cspotcode\source-map-support\source-map-support.js:461:20) at prepareStackTrace (C:\Users\user\repo\node_modules\@cspotcode\source-map-support\source-map-support.js:541:41) at Function.prepareStackTrace (C:\Users\user\repo\node_modules\tslog\src\CallSitesHelper.ts:59:31) at maybeOverridePrepareStackTrace (node:internal/errors:141:29) at prepareStackTrace (node:internal/errors:115:5) error Command failed with exit code 1.

OS: Windows 10 Pro version 21H2 it only happens on Windows and Linux subsystem for windows, I wasn't able to replicate on Mac OS or a native Linux machine.

It mostly happens when using node 16. I haven't observed the issue as much when rolling back to 14

cspotcode commented 2 years ago

@GhaithZamrik

I can't say what are the reproducible steps per se as there's nothing special about the project.

https://en.wikipedia.org/wiki/Minimal_reproducible_example

a collection of source code and other data files which allow a bug or problem to be demonstrated and reproduced

^^ You'll need to share exactly that.

GhaithZamrik commented 2 years ago

@cspotcode Yes, I understand that...

As I said I will share something when I have an example that I can share and reproduces the issue :)

terehov commented 2 years ago

Thank you, @cspotcode for pointing that out.

@GhaithZamrik, have you been able to extract a minimal example? I would appreciate it a lot.

terehov commented 2 years ago

I've been working on a new, completely rewritten version (4.0), which does not use this logic anymore. Can you give it a go and let me know if that solves your problem?

Thank you.

terehov commented 1 year ago

V4 is released now, so I'm going to close this issue. Feel free to open a new one if V4 didn't solve it for you.

Here are the docs: tslog.js.org

cai-zhuo commented 1 year ago

I met this issue in latest version

I met this issue again with node version: v16.18.0 @cspotcode/source-map-support: 0.8.1 I didn't find tslog in my pnpm-lock.yaml this step occurred at SSR, but i didn't find what relationship is between this and SSR @cspotcode thanks for helping

RangeError: Maximum call stack size exceeded at RegExp.exec () at retrieveSourceMapURL (/Users/bytedance/Workspace/livesaas-client/.eden-mono/temp/node_modules/.pnpm/@cspotcode+source-map-support@0.8.1/node_modules/@cspotcode/source-map-support/source-map-support.js:340:21) at Array. (/Users/bytedance/Workspace/livesaas-client/.eden-mono/temp/node_modules/.pnpm/@cspotcode+source-map-support@0.8.1/node_modules/@cspotcode/source-map-support/source-map-support.js:353:26) at /Users/bytedance/Workspace/livesaas-client/.eden-mono/temp/node_modules/.pnpm/@cspotcode+source-map-support@0.8.1/node_modules/@cspotcode/source-map-support/source-map-support.js:199:32 at mapSourcePosition (/Users/bytedance/Workspace/livesaas-client/.eden-mono/temp/node_modules/.pnpm/@cspotcode+source-map-support@0.8.1/node_modules/@cspotcode/source-map-support/source-map-support.js:383:21) at wrapCallSite (/Users/bytedance/Workspace/livesaas-client/.eden-mono/temp/node_modules/.pnpm/@cspotcode+source-map-support@0.8.1/node_modules/@cspotcode/source-map-support/source-map-support.js:592:20) at Function.prepareStackTrace (/Users/bytedance/Workspace/livesaas-client/.eden-mono/temp/node_modules/.pnpm/@cspotcode+source-map-support@0.8.1/node_modules/@cspotcode/source-map-support/source-map-support.js:671:41) at maybeOverridePrepareStackTrace (node:internal/errors:141:29) at prepareStackTrace (node:internal/errors:115:5) at /Users/bytedance/Workspace/livesaas-client/.eden-mono/temp/node_modules/.pnpm/@volcengine+rtc@4.47.1/node_modules/@volcengine/rtc/index.min.js:6:47502 at /Users/bytedance/Workspace/livesaas-client/.eden-mono/temp/node_modules/.pnpm/@volcengine+rtc@4.47.1/node_modules/@volcengine/rtc/index.min.js:6:84 at Object. (/Users/bytedance/Workspace/livesaas-client/.eden-mono/temp/node_modules/.pnpm/@volcengine+rtc@4.47.1/node_modules/@volcengine/rtc/index.min.js:6:200) at Module._compile (node:internal/modules/cjs/loader:1155:14) at Module._extensions..js (node:internal/modules/cjs/loader:1209:10) at Object.require.extensions. [as .js] (/Users/bytedance/Workspace/livesaas-client/.eden-mono/temp/node_modules/.pnpm/ts-node@10.9.1_b6b77fb7f9ad71c4cc5109308e4dc9fa/node_modules/ts-node/src/index.ts:1608:43) at Module.load (node:internal/modules/cjs/loader:1033:32)

terehov commented 1 year ago

It does not seem to be tslog related. In fact, this library is not even used by tslog anymore and tslog is dependency free. Please open an issue with the library causing this problem (source-map-support).

cai-zhuo commented 1 year ago

It does not seem to be tslog related. In fact, this library is not even used by tslog anymore and tslog is dependency free. Please open an issue with the library causing this problem (source-map-support).

ok thanks