mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-08-17 15:19:25 +00:00
fix: memory leak when scanning sketchbooks with large files (#2555)
Resolves https://github.com/arduino/arduino-ide/issues/2537 Fix memory leak issue caused by inflight dependency, see https://github.com/isaacs/node-glob/issues/435
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
const path = require('node:path');
|
||||
const { mkdirSync, promises: fs, rmSync } = require('node:fs');
|
||||
const { exec } = require('./utils');
|
||||
const glob = require('glob');
|
||||
const { glob } = require('glob');
|
||||
const { SemVer, gte, valid: validSemVer } = require('semver');
|
||||
// Use a node-protoc fork until apple arm32 is supported
|
||||
// https://github.com/YePpHa/node-protoc/pull/10
|
||||
@@ -147,16 +147,14 @@
|
||||
rmSync(out, { recursive: true, maxRetries: 5, force: true });
|
||||
mkdirSync(out, { recursive: true });
|
||||
|
||||
const protos = await new Promise((resolve) =>
|
||||
glob('**/*.proto', { cwd: rpc }, (error, matches) => {
|
||||
if (error) {
|
||||
console.log(error.stack ?? error.message);
|
||||
resolve([]);
|
||||
return;
|
||||
}
|
||||
resolve(matches.map((filename) => path.join(rpc, filename)));
|
||||
})
|
||||
);
|
||||
let protos = [];
|
||||
try {
|
||||
const matches = await glob('**/*.proto', { cwd: rpc });
|
||||
protos = matches.map((filename) => path.join(rpc, filename));
|
||||
} catch (error) {
|
||||
console.log(error.stack ?? error.message);
|
||||
}
|
||||
|
||||
if (!protos || protos.length === 0) {
|
||||
console.log(`Could not find any .proto files under ${rpc}.`);
|
||||
process.exit(1);
|
||||
|
Reference in New Issue
Block a user