tslog icon indicating copy to clipboard operation
tslog copied to clipboard

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

Open cspotcode opened this issue 3 years ago • 4 comments

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.

cspotcode avatar Jun 01 '22 21:06 cspotcode

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

GhaithZamrik avatar Jun 02 '22 08:06 GhaithZamrik

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

cspotcode avatar Jun 02 '22 15:06 cspotcode

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

GhaithZamrik avatar Jun 02 '22 15:06 GhaithZamrik

Thank you, @cspotcode for pointing that out.

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

terehov avatar Aug 23 '22 19:08 terehov

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?

  • npm i tslog@next

  • and run it with node --enable-source-maps or for TypeScript node --enable-source-maps --experimental-specifier-resolution=node --no-warnings --loader ts-node/esm

Thank you.

terehov avatar Sep 29 '22 10:09 terehov

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

terehov avatar Nov 15 '22 18:11 terehov

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/@[email protected]/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/@[email protected]/node_modules/@cspotcode/source-map-support/source-map-support.js:353:26) at /Users/bytedance/Workspace/livesaas-client/.eden-mono/temp/node_modules/.pnpm/@[email protected]/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/@[email protected]/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/@[email protected]/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/@[email protected]/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/@[email protected]/node_modules/@volcengine/rtc/index.min.js:6:47502 at /Users/bytedance/Workspace/livesaas-client/.eden-mono/temp/node_modules/.pnpm/@[email protected]/node_modules/@volcengine/rtc/index.min.js:6:84 at Object. (/Users/bytedance/Workspace/livesaas-client/.eden-mono/temp/node_modules/.pnpm/@[email protected]/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/[email protected]_b6b77fb7f9ad71c4cc5109308e4dc9fa/node_modules/ts-node/src/index.ts:1608:43) at Module.load (node:internal/modules/cjs/loader:1033:32)

cai-zhuo avatar Nov 30 '22 04:11 cai-zhuo

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

terehov avatar Nov 30 '22 05:11 terehov

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

cai-zhuo avatar Dec 07 '22 06:12 cai-zhuo