node-source-map-support icon indicating copy to clipboard operation
node-source-map-support copied to clipboard

RangeError Maximum call stack size exceeded when testing Vue project

Open gcampbell-msft opened this issue 3 years ago • 1 comments

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\[email protected]\node_modules\source-map-support\source-map-support.js:174:21)
    at Array.<anonymous> (D:\a\_work\1\s\common\temp\node_modules\.pnpm\[email protected]\node_modules\source-map-support\source-map-support.js:186:26)
    at D:\a\_work\1\s\common\temp\node_modules\.pnpm\[email protected]\node_modules\source-map-support\source-map-support.js:85:24
    at mapSourcePosition (D:\a\_work\1\s\common\temp\node_modules\.pnpm\[email protected]\node_modules\source-map-support\source-map-support.js:216:21)
    at wrapCallSite (D:\a\_work\1\s\common\temp\node_modules\.pnpm\[email protected]\node_modules\source-map-support\source-map-support.js:397:20)
    at Function.prepareStackTrace (D:\a\_work\1\s\common\temp\node_modules\.pnpm\[email protected]\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\[email protected][email protected][email protected]\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.

gcampbell-msft avatar Aug 05 '22 19:08 gcampbell-msft

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.

FLabastida avatar Mar 08 '23 00:03 FLabastida