earendil-works/pi · error · TypeError

Unix transport maxPendingBytes must be a positive safe integ

Error message

Unix transport maxPendingBytes must be a positive safe integer

What it means

Error "Unix transport maxPendingBytes must be a positive safe integer" thrown in earendil-works/pi.

Source

Thrown at packages/client/src/unix.ts:20

import { DEFAULT_MAX_FRAME_LENGTH } from "@earendil-works/pi-protocol";
import type { ByteTransport, ByteTransportFactory, ByteTransportHandlers } from "./transport.ts";

const MAX_UNIX_SOCKET_PATH_BYTES = process.platform === "linux" ? 107 : 103;

export interface UnixTransportOptions {
	path: string;
	maxPendingBytes?: number;
}

/** Creates fresh Unix-domain socket transports for PiClient connection attempts in Node-compatible runtimes. */
export function createUnixTransportFactory(options: UnixTransportOptions): ByteTransportFactory {
	if (options.path.length === 0) throw new TypeError("Unix transport path must not be empty");
	if (Buffer.byteLength(options.path) > MAX_UNIX_SOCKET_PATH_BYTES) {
		throw new TypeError(`Unix transport path is too long; maximum is ${MAX_UNIX_SOCKET_PATH_BYTES} UTF-8 bytes`);
	}
	const maxPendingBytes = options.maxPendingBytes ?? DEFAULT_MAX_FRAME_LENGTH * 4;
	if (!Number.isSafeInteger(maxPendingBytes) || maxPendingBytes <= 0) {
		throw new TypeError("Unix transport maxPendingBytes must be a positive safe integer");
	}
	if (process.platform === "win32") throw new Error("Unix transport is not supported on Windows");
	return (handlers) => connectUnixSocket(options.path, maxPendingBytes, handlers);
}

function connectUnixSocket(
	path: string,
	maxPendingBytes: number,
	handlers: ByteTransportHandlers,
): Promise<ByteTransport> {
	return new Promise<ByteTransport>((resolve, reject) => {
		const socket = createConnection(path);
		let connected = false;
		let terminal = false;

		const close = (): void => {
			if (terminal) return;
			terminal = true;

View on GitHub (pinned to 4af9d21d3b)

When it happens

Trigger: Thrown at packages/client/src/unix.ts:20 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/ab1c7dd11cf27da6. Report an issue: GitHub.