When an api/addPkg job is dequeued, server/src/engine/queue.ts reads the package from disk and sends it to the compiler as a base64 string:
} else if (job.request === jobs.Request.apiAddPkg && (job.src === null || job.src === undefined)) {
const base64 = fs.readFileSync(fileURLToPath(job.uri!)).toString('base64')
socket.sendMessage({ ...job, base64 })
}
The compiler does not need the contents. It runs as a local child process (see process.ts), the package URI is always a local file: URI produced by vsCodeUriToUriString, and the same URI is already sent as-is for api/addJar, which the compiler resolves to a path itself. Unlike .flix files, a package has no unsaved editor buffer, so job.src is never set for a package job and the guard is vestigial.
flix/flix#13292 changes the compiler to read the package from the file at the URI and to ignore a base64 field if one is present. Once a release containing that change is the minimum supported compiler, the extension can drop the branch above and send api/addPkg jobs unchanged, exactly like api/addJar jobs. Until then the extension must keep sending the field, since older compilers reject an api/addPkg request without it.
This removes a full read and base64 encoding of every package on startup and on every change under lib/, and it shrinks the message from the size of the archive to a URI.
When an
api/addPkgjob is dequeued,server/src/engine/queue.tsreads the package from disk and sends it to the compiler as a base64 string:The compiler does not need the contents. It runs as a local child process (see
process.ts), the package URI is always a localfile:URI produced byvsCodeUriToUriString, and the same URI is already sent as-is forapi/addJar, which the compiler resolves to a path itself. Unlike.flixfiles, a package has no unsaved editor buffer, sojob.srcis never set for a package job and the guard is vestigial.flix/flix#13292 changes the compiler to read the package from the file at the URI and to ignore a
base64field if one is present. Once a release containing that change is the minimum supported compiler, the extension can drop the branch above and sendapi/addPkgjobs unchanged, exactly likeapi/addJarjobs. Until then the extension must keep sending the field, since older compilers reject anapi/addPkgrequest without it.This removes a full read and base64 encoding of every package on startup and on every change under
lib/, and it shrinks the message from the size of the archive to a URI.