8000 fix: update `glob` version to fix memory leak · arduino/arduino-ide@cf78a68 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cf78a68

Browse files
fix: update glob version to fix memory leak
Resolves #2537 Fix memory leak issue caused by inflight dependency, see isaacs/node-glob#435
1 parent 3ccc864 commit cf78a68

File tree

5 files changed

+244
-94
lines changed

5 files changed

+244
-94
lines changed

arduino-ide-extension/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"fast-safe-stringify": "^2.1.1",
7474
"filename-reserved-regex": "^2.0.0",
7575
"fqbn": "^1.0.5",
76-
"glob": "^7.1.6",
76+
"glob": "10.4.4",
7777
"google-protobuf": "^3.20.1",
7878
"hash.js": "^1.1.7",
7979
"is-online": "^10.0.0",
@@ -127,8 +127,8 @@
127127
"rimraf": "^2.6.1"
128128
},
129129
"optionalDependencies": {
130-
"grpc-tools": "^1.12.4",
131-
"@pingghost/protoc": "^1.0.2"
130+
"@pingghost/protoc": "^1.0.2",
131+
"grpc-tools": "^1.12.4"
132132
},
133133
"mocha": {
134134
"require": [

arduino-ide-extension/scripts/generate-protocol.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
const path = require('node:path');
66
const { mkdirSync, promises: fs, rmSync } = require('node:fs');
77
const { exec } = require('./utils');
8-
const glob = require('glob');
8+
const { glob } = require('glob');
99
const { SemVer, gte, valid: validSemVer } = require('semver');
1010
// Use a node-protoc fork until apple arm32 is supported
1111
// https://github.com/YePpHa/node-protoc/pull/10
@@ -147,16 +147,14 @@
147147
rmSync(out, { recursive: true, maxRetries: 5, force: true });
148148
mkdirSync(out, { recursive: true });
149149

150-
const protos = await new Promise((resolve) =>
151-
glob('**/*.proto', { cwd: rpc }, (error, matches) => {
152-
if (error) {
153-
console.log(error.stack ?? error.message);
154-
resolve([]);
155-
return;
156-
}
157-
resolve(matches.map((filename) => path.join(rpc, filename)));
158-
})
159-
);
150+
let protos = [];
151+
try {
152+
const matches = await glob('**/*.proto', { cwd: rpc });
153+
protos = matches.map((filename) => path.join(rpc, filename));
154+
} catch (error) {
155+
console.log(error.stack ?? error.message);
156+
}
157+
160158
if (!protos || protos.length === 0) {
161159
console.log(`Could not find any .proto files under ${rpc}.`);
162160
process.exit(1);

arduino-ide-extension/src/node/sketches-service-impl.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { Mutable } from '@theia/core/lib/common/types';
88
import URI from '@theia/core/lib/common/uri';
99
import { FileUri } from '@theia/core/lib/node/file-uri';
1010
import { inject, injectable, named } from '@theia/core/shared/inversify';
11-
import glob from 'glob';
11+
import { glob } from 'glob';
1212
import crypto from 'node:crypto';
1313
import {
1414
CopyOptions,
@@ -853,13 +853,13 @@ export async function discoverSketches(
853853
container: Mutable<SketchContainer>,
854854
logger?: ILogger
855855
): Promise<SketchContainer> {
856-
const pathToAllSketchFiles = await globSketches(
856+
const pathToAllSketchFiles = await glob(
857857
'/!(libraries|hardware)/**/*.{ino,pde}',
858-
root
858+
{ root }
859859
);
860860
// if no match try to glob the sketchbook as a sketch folder
861861
if (!pathToAllSketchFiles.length) {
862-
pathToAllSketchFiles.push(...(await globSketches('/*.{ino,pde}', root)));
862+
pathToAllSketchFiles.push(...(await glob('/*.{ino,pde}', { root })));
863863
}
864864

865865
// Sort by path length to filter out nested sketches, such as the `Nested_folder` inside the `Folder` sketch.
@@ -873,7 +873,14 @@ export async function discoverSketches(
873873
// +--Nested_folder
874874
// |
875875
// +--Nested_folder.ino
876-
pathToAllSketchFiles.sort((left, right) => left.length - right.length);
876+
pathToAllSketchFiles.sort((left, right) => {
877+
if (left.length === right.length) {
878+
// Sort alphabetically for tests consistency
879+
return left.localeCompare(right);
880+
}
881+
return left.length - right.length;
882+
});
883+
877884
const getOrCreateChildContainer = (
878885
container: SketchContainer,
879886
segments: string[]
@@ -974,17 +981,6 @@ export async function discoverSketches(
974981
uri: FileUri.create(path.dirname(pathToSketchFile)).toString(),
975982
});
976983
}
977-
return prune(container);
978-
}
979984

980-
async function globSketches(pattern: string, root: string): Promise<string[]> {
981-
return new Promise<string[]>((resolve, reject) => {
982-
glob(pattern, { root }, (error, results) => {
983-
if (error) {
984-
reject(error);
985-
} else {
986-
resolve(results);
987-
}
988-
});
989-
});
985+
return prune(container);
990986
}

electron-app/scripts/post-package.js

Lines changed: 1 addition & 7485 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
const isCI = require('is-ci');
55
const fs = require('fs');
66
const path = require('path');
7-
const glob = require('glob');
7+
const { glob } = require('glob');
88
const { isRelease } = require('./utils');
99
const { isZip, adjustArchiveStructure } = require('./archive');
1010

0 commit comments

Comments
 (0)
0