[Bug][Windows] koffi is load-bearing (session JSONL atomic writes, win32 process/acl) but fails late and confusingly under embedded Node #6461
nanami-0713
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
On Windows, several core paths depend on the native FFI package koffi, loaded lazily at first use:
dsh-session-persistence-jsonl:(await import("koffi")).default.load("kernel32.dll")→MoveFileExW, used for atomic session JSONL writes;dsh-win32-processanddsh-sandbox-windows-aclalso bind through koffi.koffi ships prebuilds for standard Node layouts, but under an embedded runtime with a different ABI (different
NODE_MODULE_VERSION) — e.g. Electron's bundled Node — the prebuild fails to load. koffi's documented rescue hatch is a fallback binary at<resourcesPath>/koffi/<platform>_<arch>/koffi.node, which the embedder must arrange per platform itself.Because the import is lazy, the failure surfaces far from its cause: a raw module-load error in the middle of normal operation (first session write / first process operation) rather than a startup-time diagnostic, and
dsh weboffers no actionable message.What we would wish for
resourcesPathworkaround;dsh webinside Electron shells, and this is the single most surprising Windows pitfall.Workaround we use today
When packaging our Electron shell for Windows we inject the win32-x64 koffi prebuild into the documented fallback location (
resources/koffi/win32_x64/koffi.nodeviaextraResources) and skip native rebuilds; with that in place, session persistence works. Making this contract official (or unnecessary) would make Windows packaging reliable for every embedder.Environment
Windows x64 (10/11), dsh 0.1.x hosted under Electron's Node (ABI mismatch vs system Node), koffi win32-x64 prebuild injected via the
resourcesPathfallback.All reactions