github/copilot-sdk · error

In-process FFI runtime host not started

Error message

In-process FFI runtime host not started

What it means

State guard in CopilotClient: code tried to use the in-process FFI runtime host (this.ffiHost) before FfiRuntimeHost.start() completed or after it failed/stopped. The receive/send streams needed for JSON-RPC framing do not exist until the host is running, so the client has no transport.

Solutions

  1. Await the client's connect/start flow that creates and starts the FFI host before issuing any requests
  2. Check that the runtime library loaded correctly (correct platform artifact and entrypoint) - a failed start leaves the host unset
  3. Fall back to the stdio or TCP transport if the FFI runtime library is unavailable on this platform
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nodejs/src/client.ts:2858 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09). Data as JSON: /api/errors/f89c3f6788c96f13. Report an issue: GitHub.

Appendix: source

Thrown at nodejs/src/client.ts:2858

        if (this.options.sessionIdleTimeoutSeconds > 0) {
            args.push("--session-idle-timeout", this.options.sessionIdleTimeoutSeconds.toString());
        }
        if (this.options.enableRemoteSessions) {
            args.push("--remote");
        }

        const host = FfiRuntimeHost.create(runtimeLibrary, explicitEntrypoint, environment, args);
        this.ffiHost = host;
        await host.start();
    }

    /**
     * Connect to the in-process FFI runtime host over its receive/send streams,
     * reusing the same `vscode-jsonrpc` framing as the stdio transport.
     */
    private async connectViaFfi(): Promise<void> {
        if (!this.ffiHost) {
            throw new Error("In-process FFI runtime host not started");
        }
        this.messageWriter = new TeardownResilientStreamMessageWriter(this.ffiHost.sendStream);
        this.connection = createMessageConnection(
            new StreamMessageReader(this.ffiHost.receiveStream),
            this.messageWriter
        );

        this.attachConnectionHandlers();
        this.connection.listen();
    }

    private static getNapiPrebuildsFolder(entrypoint: string): string {
        const arch = process.arch;
        if (arch !== "x64" && arch !== "arm64") {
            throw new Error(`Unsupported architecture '${arch}' for in-process FFI hosting.`);
        }
        let platform: string = process.platform;
        if (platform === "linux" && CopilotClient.isMusl(entrypoint)) {

View on GitHub (pinned to cd8cf15dc3)