Skip to content

Commit 7ce9ef9

Browse files
committed
Use concat instead of push around listFolders
This avoids stack overflows when using the spread operator on directories that have many, many children.
1 parent 1e7f770 commit 7ce9ef9

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

lib/analyze-action.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze-action.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/analyze-action.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,19 @@ async function run() {
151151

152152
if (config.debugMode) {
153153
// Upload the logs as an Actions artifact for debugging
154-
const toUpload: string[] = [];
154+
let toUpload: string[] = [];
155155
for (const language of config.languages) {
156-
toUpload.push(
157-
...listFolder(
156+
toUpload = toUpload.concat(
157+
listFolder(
158158
path.resolve(util.getCodeQLDatabasePath(config, language), "log")
159159
)
160160
);
161161
}
162162
if (await codeQlVersionAbove(codeql, CODEQL_VERSION_NEW_TRACING)) {
163163
// Multilanguage tracing: there are additional logs in the root of the cluster
164-
toUpload.push(...listFolder(path.resolve(config.dbLocation, "log")));
164+
toUpload = toUpload.concat(
165+
listFolder(path.resolve(config.dbLocation, "log"))
166+
);
165167
}
166168
await uploadDebugArtifacts(
167169
toUpload,
@@ -319,12 +321,12 @@ async function uploadDebugArtifacts(
319321

320322
function listFolder(dir: string): string[] {
321323
const entries = fs.readdirSync(dir, { withFileTypes: true });
322-
const files: string[] = [];
324+
let files: string[] = [];
323325
for (const entry of entries) {
324326
if (entry.isFile()) {
325327
files.push(path.resolve(dir, entry.name));
326328
} else if (entry.isDirectory()) {
327-
files.push(...listFolder(path.resolve(dir, entry.name)));
329+
files = files.concat(listFolder(path.resolve(dir, entry.name)));
328330
}
329331
}
330332
return files;

0 commit comments

Comments
 (0)