- Rollup Version: 9c436a7 (2.52.3)
- Operating System (or Browser): MacOS
- Node Version (if applicable): 12.22.1
- Link to reproduction: nolanlawson@ab4c7fc
git clone git@github.com:nolanlawson/rollup.git
cd rollup
git checkout repro-max-call-stack
npm i
npm run test:quick
Expected Behavior
When parsing a JavaScript source file containing enough nesting that Node throws a RangeError: Maximum call stack size exceeded, I would expect to see an error with that message (or similar message) thrown by rollup.rollup().
Actual Behavior
Instead of the Maximum call stack size exceeded error, the following error is thrown:
TypeError: Cannot destructure property 'column' of 'locate(...)' as it is undefined.
at Module.addLocationToLogProps (/Users/nlawson/workspace/rollup/dist/shared/rollup.js:10413:15)
at Module.error (/Users/nlawson/workspace/rollup/dist/shared/rollup.js:9887:14)
at Module.tryParse (/Users/nlawson/workspace/rollup/dist/shared/rollup.js:10287:25)
at Module.setSource (/Users/nlawson/workspace/rollup/dist/shared/rollup.js:10190:24)
at ModuleLoader.addModuleSource (/Users/nlawson/workspace/rollup/dist/shared/rollup.js:19504:20)
at async ModuleLoader.fetchModule (/Users/nlawson/workspace/rollup/dist/shared/rollup.js:19560:9)
at async Promise.all (index 0)
The issue is that the actual max call stack error is caught and handled here:
|
return this.error( |
|
{ |
|
code: 'PARSE_ERROR', |
|
message, |
|
parserError: err |
|
}, |
|
err.pos |
|
); |
But then the error-handling code itself runs into an error, because the locate function returns undefined:
|
let { column, line } = locate(code!, pos, { offsetLine: 1 }); |
This behavior can be confusing, since it's not obvious that the actual problem is a max call stack error.
git clone git@github.com:nolanlawson/rollup.git cd rollup git checkout repro-max-call-stack npm i npm run test:quickExpected Behavior
When parsing a JavaScript source file containing enough nesting that Node throws a
RangeError: Maximum call stack size exceeded, I would expect to see an error with that message (or similar message) thrown byrollup.rollup().Actual Behavior
Instead of the
Maximum call stack size exceedederror, the following error is thrown:The issue is that the actual max call stack error is caught and handled here:
rollup/src/Module.ts
Lines 804 to 811 in 7212516
But then the error-handling code itself runs into an error, because the
locatefunction returnsundefined:rollup/src/Module.ts
Line 947 in 7212516
This behavior can be confusing, since it's not obvious that the actual problem is a max call stack error.