Skip to content

Stop sending the contents of .fpkg files in api/addPkg #570

Description

@magnus-madsen

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions