evanw / node-source-map-support

Adds source map support to node.js (for stack traces)
MIT License
2.16k stars 222 forks source link

RangeError Maximum call stack size exceeded when testing Vue project #319

Open gcampbell-msft opened 1 year ago

gcampbell-msft commented 1 year ago

Hi, this is somewhat of a duplicate of these issues: #252, #249, and #86. But I wanted to call more attention to it.

I am getting this error when attempting to test our Vue project using vue-cli-service :

RangeError: Maximum call stack size exceeded
    at RegExp.exec (<anonymous>)
    at retrieveSourceMapURL (D:\a\_work\1\s\common\temp\node_modules\.pnpm\source-map-support@0.5.21\node_modules\source-map-support\source-map-support.js:174:21)
    at Array.<anonymous> (D:\a\_work\1\s\common\temp\node_modules\.pnpm\source-map-support@0.5.21\node_modules\source-map-support\source-map-support.js:186:26)
    at D:\a\_work\1\s\common\temp\node_modules\.pnpm\source-map-support@0.5.21\node_modules\source-map-support\source-map-support.js:85:24
    at mapSourcePosition (D:\a\_work\1\s\common\temp\node_modules\.pnpm\source-map-support@0.5.21\node_modules\source-map-support\source-map-support.js:216:21)
    at wrapCallSite (D:\a\_work\1\s\common\temp\node_modules\.pnpm\source-map-support@0.5.21\node_modules\source-map-support\source-map-support.js:397:20)
    at Function.prepareStackTrace (D:\a\_work\1\s\common\temp\node_modules\.pnpm\source-map-support@0.5.21\node_modules\source-map-support\source-map-support.js:446:39)
    at maybeOverridePrepareStackTrace (node:internal/errors:141:29)
    at prepareStackTrace (node:internal/errors:115:5)
    at TestRunner.Reporter.onLoadingException (D:\a\_work\1\s\common\temp\node_modules\.pnpm\mochapack@2.1.4_mocha@8.4.0+webpack@5.72.0\node_modules\mochapack\src\runner\testRunnerReporter.ts:104:13)

The version of our source-map-support is 0.5.21.

I believe the issue is coming from having large source maps that are being pulled in during the test, and the regex trying to scan through it. Is there a way to fix this to help further avoid this error?

Let me know if there's anything I can help out with in terms of solving this, or if there's anything more I should understand about the current state of the code and why this issue is happening.

FLabastida commented 1 year ago

Similar issue with serverles-offline plugin and only for testing in local environment

LocalEnvironment:

OS : Arch Linux x86_64
Nodejs: 19.7.0
@cspotcode/source-map-support: 0.8.1
serverless-offline: 8.8.0

Error:

 RangeError: Maximum call stack size exceeded
    at RegExp.exec (<anonymous>)
    at retrieveSourceMapURL (/app/node_modules/@cspotcode/source-map-support/source-map-support.js:340:21)

When set a timeout for avoid the RangeError, the app flow can continue

setTimeout(()=>{
    try {
      while (match = re.exec(fileData)) lastMatch = match
    } catch (error) {
      console.error('Timeout',error.message)
      return null
    }
    }, 100)

This works for local development and now the flow is

start app
...before normal flow app
Timeout error
...after normal flow app

This only works for special purposes for local development when source-map-support is a dev dependency, please let me know if have the solution for this problem.