Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid Maximum call stack size exceeded #2162

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

mguaypaq
Copy link
Contributor

Using spread syntax (...SomeIterable) with a long list inside a function call (in this case, Array.prototype.push) can result in a "Maximum call stack size exceeded" error. But this is not a problem inside array literals.

I ran into this when running bids-validator on the command-line, on a relatively small dataset (~350 subjects, each with ~2 sessions, all sessions labeled with unique dates because no-one understands that part of the standard).

Before the fix:

1: [ERR] Internal error. SOME VALIDATION STEPS MAY NOT HAVE OCCURRED (code: 0 - INTERNAL ERROR)
		Evidence: RangeError: Maximum call stack size exceeded
    at missingSessionFiles (/home/mguaypaq/.local/share/node-v20.16.0-linux-x64/lib/node_modules/bids-validator/dist/commonjs/cli.js:136164:11)
    at /home/mguaypaq/.local/share/node-v20.16.0-linux-x64/lib/node_modules/bids-validator/dist/commonjs/cli.js:137078:42

The error disappeared when I applied this change directly in the compiled cli.js around line 136164.

There are a few other cases of the push(...SomeIterable) pattern elsewhere in the repo, but I'm not confident enough to touch them.

Copy link

codecov bot commented Oct 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.51%. Comparing base (35306a2) to head (4671868).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2162      +/-   ##
==========================================
+ Coverage   85.73%   87.51%   +1.77%     
==========================================
  Files          91      133      +42     
  Lines        3785     7047    +3262     
  Branches     1220     1669     +449     
==========================================
+ Hits         3245     6167    +2922     
- Misses        454      785     +331     
- Partials       86       95       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Using spread syntax `...SomeIterable` with a long list inside a
function call can result in a "Maximum call stack size exceeded"
error. But this is not a problem inside array literals.
@effigies effigies merged commit b85c545 into bids-standard:master Oct 16, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants