From 4671868d4ba51d8ed3208bf6ba21a1282a333d2e Mon Sep 17 00:00:00 2001 From: Mathieu Guay-Paquet Date: Tue, 15 Oct 2024 14:20:19 -0400 Subject: [PATCH] fix: avoid Maximum call stack size exceeded 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. --- bids-validator/validators/session.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/bids-validator/validators/session.js b/bids-validator/validators/session.js index e7d8ead00..a17f23717 100644 --- a/bids-validator/validators/session.js +++ b/bids-validator/validators/session.js @@ -11,15 +11,12 @@ import isNode from '../utils/isNode' * files from the set. */ const session = function missingSessionFiles(fileList) { - const issues = [] const { subjects, sessions } = getDataOrganization(fileList) - - issues.push(...missingSessionWarnings(subjects, sessions)) - const subject_files = getSubjectFiles(subjects) - issues.push(...missingFileWarnings(subjects, subject_files)) - - return issues + return [ + ...missingSessionWarnings(subjects, sessions), + ...missingFileWarnings(subjects, subject_files), + ] } /**