procxy / ProcxyOptions
Type Alias: ProcxyOptions<Mode, SupportHandles>
ts
type ProcxyOptions<Mode, SupportHandles> = {
args?: [...Jsonifiable[]];
cwd?: string;
env?: Record<string, string>;
interleaveOutput?: boolean;
modulePath?: string;
retries?: number;
timeout?: number;
} & Mode extends "advanced" ? {
sanitizeV8?: boolean;
serialization: "advanced";
supportHandles?: SupportHandles;
} : {
serialization?: "json";
};Defined in: src/types/options.ts:46
Config
Configuration for the procxy() function.
Controls child process spawning, IPC serialization, timeouts, retries, environment isolation, and optional handle-passing support.
Type Declaration
| Name | Type | Description | Defined in |
|---|---|---|---|
args? | [...Jsonifiable[]] | Arguments to pass to the child process (via process.argv). All values must be JSON-serializable (type-fest's Jsonifiable). Default undefined | src/types/options.ts:67 |
cwd? | string | Working directory for the child process. Must be an absolute path to an existing directory. Default undefined (inherits parent's cwd) | src/types/options.ts:83 |
env? | Record<string, string> | Environment variables for the child process. All values must be strings. Default undefined (inherits parent's environment) | src/types/options.ts:75 |
interleaveOutput? | boolean | Forward child process stdout and stderr to parent's stdout and stderr. When enabled, all console.log(), console.error(), and other output from the child process will be displayed in the parent process in real-time. Default false | src/types/options.ts:129 |
modulePath? | string | Path to the module containing the class. Can be specified here or as the second parameter to procxy(). If not provided, procxy will attempt to auto-detect the module path from the class constructor's source location. Default undefined (auto-detect from class) | src/types/options.ts:59 |
retries? | number | Number of retry attempts per method call (in addition to the initial attempt). For example, retries: 3 means 4 total attempts (1 initial + 3 retries). Each retry uses the same timeout, so total time = timeout * (retries + 1). Default 3 | src/types/options.ts:101 |
timeout? | number | Timeout in milliseconds for each remote method call. When timeout expires, the Promise is rejected with TimeoutError. The child process continues running (is not killed). Default 30000 (30 seconds) | src/types/options.ts:92 |
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
Mode extends SerializationMode | "json" | Serialization mode: 'json' (default) or 'advanced' |
SupportHandles extends boolean | false | Literal boolean controlling whether $sendHandle appears on the proxy |
Remarks
Most options have sensible defaults; only modulePath is ever strictly required, and even that is optional when automatic module resolution succeeds. Pass the object as the second or third argument to procxy():
typescript
// Inline — TypeScript infers Mode from `serialization`
await procxy(MyClass, './my-class.js', { timeout: 10_000 });
// Named — use `as const` so `serialization` literal is preserved for type narrowing
const opts = { serialization: 'advanced', supportHandles: true } as const;
await procxy(MyClass, './my-class.js', opts);