From 6010f85d81311aee3e4d090b444e82855e90740b Mon Sep 17 00:00:00 2001 From: Mario Campos Date: Wed, 3 Jun 2026 16:41:50 -0500 Subject: [PATCH] Reimplement `resolveExtractor()` as wrapper over `resolveLanguages()` By wrapping `resolveLanguages()`, which is memoized, we can avoid executing `codeql resolve extractor` several times over the course of an analysis. --- src/codeql.ts | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/src/codeql.ts b/src/codeql.ts index 0747830d0..626d1021a 100644 --- a/src/codeql.ts +++ b/src/codeql.ts @@ -946,32 +946,11 @@ async function getCodeQLForCmd( await new toolrunner.ToolRunner(cmd, args).exec(); }, async resolveExtractor(language: Language): Promise { - // Request it using `format=json` so we don't need to strip the trailing new line generated by - // the CLI. - let extractorPath = ""; - await new toolrunner.ToolRunner( - cmd, - [ - "resolve", - "extractor", - "--format=json", - `--language=${language}`, - "--extractor-include-aliases", - ...getExtraOptionsFromEnv(["resolve", "extractor"]), - ], - { - silent: true, - listeners: { - stdout: (data) => { - extractorPath += data.toString(); - }, - stderr: (data) => { - process.stderr.write(data); - }, - }, - }, - ).exec(); - return JSON.parse(extractorPath) as string; + // A previous implementation executed `codeql resolve extractor`. + // This can be a bit slow due to the JVM startup cost. Instead, get + // the extractor path from resolveLanguages(), which caches its output. + const extractors = await this.resolveLanguages(); + return extractors[language][0]; }, async resolveQueriesStartingPacks(queries: string[]): Promise { const codeqlArgs = [