From 148bd69c06f2ee01e1782207cf7d543e951edfa3 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 23 Sep 2026 12:39:52 +0200 Subject: [PATCH] Give the raw promisified nextEvent its own 6-argument type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The wrapper cast the raw promisified koffi call to the same 4-argument public NativeBindings#nextEventAsync type it was implementing, then called it with six arguments (the two _Out_ placeholders included) — a type checked itself into a contradiction tsc caught on a clean build. The raw call gets its own type matching what koffi actually expects; the public wrapper still exposes four. Co-Authored-By: Claude Sonnet 5 --- packages/cultmesh-ts/src/realtime-quic-native.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/cultmesh-ts/src/realtime-quic-native.ts b/packages/cultmesh-ts/src/realtime-quic-native.ts index eab33595..221c40e3 100644 --- a/packages/cultmesh-ts/src/realtime-quic-native.ts +++ b/packages/cultmesh-ts/src/realtime-quic-native.ts @@ -215,7 +215,14 @@ function loadBindings(): NativeBindings { // eslint-disable-next-line @typescript-eslint/no-var-requires const { promisify } = require("node:util") as typeof import("node:util"); - const nextEventAsync = promisify(nextEvent.async) as NativeBindings["nextEventAsync"]; + const nextEventAsyncRaw = promisify(nextEvent.async) as ( + runtime: unknown, + timeoutMs: number, + outEvent: null, + payload: Uint8Array | null, + payloadCapacity: number, + outRequired: null, + ) => Promise>; // Every `_Out_` parameter still occupies a call-site slot in this koffi // version (an arity check rejects a shorter call); its value is written @@ -236,7 +243,7 @@ function loadBindings(): NativeBindings { streamSendFrame(runtime, streamId, encodedFrame, length, fin), streamShutdown: (runtime, streamId, code) => streamShutdown(runtime, streamId, code), nextEventAsync: (runtime, timeoutMs, payload, payloadCapacity) => - nextEventAsync(runtime, timeoutMs, null, payload, payloadCapacity, null) as Promise>, + nextEventAsyncRaw(runtime, timeoutMs, null, payload, payloadCapacity, null), lastError: (runtime, destination, capacity) => lastError(runtime, destination, capacity), lastStatus: (runtime) => lastStatus(runtime), };