From cfaa353447ca7ec64053c0bdfdb744e0c27b3ad3 Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Mon, 22 Jan 2024 09:37:53 -0700 Subject: [PATCH 1/2] fix: make dep resolution deterministic --- src/commands/plugins/inspect.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/commands/plugins/inspect.ts b/src/commands/plugins/inspect.ts index aae9ae75..10a23ab9 100644 --- a/src/commands/plugins/inspect.ts +++ b/src/commands/plugins/inspect.ts @@ -70,18 +70,21 @@ export default class PluginsInspect extends Command { paths.push(start) } - try { - return await Promise.any( - paths.map(async (p) => { - const fullPath = join(p, dependencyPath) - const pkgJsonPath = join(fullPath, 'package.json') - const pkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf8')) - return {pkgPath: fullPath, version: pkgJson.version as string} - }), - ) - } catch { - return {pkgPath: null, version: null} + // NOTE: we cannot parallelize this because we need to check the order of the paths matters. + // Parallelizing this would be faster, but would make the result non-deterministic. + for (const p of paths) { + try { + const fullPath = join(p, dependencyPath) + const pkgJsonPath = join(fullPath, 'package.json') + // eslint-disable-next-line no-await-in-loop + const pkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf8')) + return {pkgPath: fullPath, version: pkgJson.version as string} + } catch { + // try the next path + } } + + return {pkgPath: null, version: null} } findPlugin(pluginName: string): Plugin { From 3c02f0c7de1762e09b81664f7c974dce72f56c8f Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Mon, 22 Jan 2024 09:40:44 -0700 Subject: [PATCH 2/2] chore: clarify note --- src/commands/plugins/inspect.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/plugins/inspect.ts b/src/commands/plugins/inspect.ts index 10a23ab9..009c54db 100644 --- a/src/commands/plugins/inspect.ts +++ b/src/commands/plugins/inspect.ts @@ -70,7 +70,7 @@ export default class PluginsInspect extends Command { paths.push(start) } - // NOTE: we cannot parallelize this because we need to check the order of the paths matters. + // NOTE: we cannot parallelize this because we need to check the paths in the order they were found. // Parallelizing this would be faster, but would make the result non-deterministic. for (const p of paths) { try {