t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: Nightly desktop app never opens a window — backend crash-loops on missing @yuuang/ffi-rs native binding

Open akj opened this issue 5 months ago • 3 comments

Summary

The desktop app launches a main process but never opens a window because the bundled backend server crash-loops on startup with a missing native module. Affected build: 0.0.28-nightly.20260616.571 (nightly channel, Windows x64). The packaging gap also affects mac/linux nightlies (see below).

The backend exits immediately with:

Error: Cannot find module '@yuuang/ffi-rs-win32-x64-msvc'
Require stack:
- <install>\resources\app.asar\node_modules\ffi-rs\index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1483:15)
    ...
Node.js v24.15.0

Symptoms

  • A T3 Code (Nightly).exe main process is running (plus GPU + network-service helpers), but no renderer/window ever appears.
  • Killing and restarting the app does not help — every launch reproduces it.
  • server-child.log shows the backend child spawning and dying with code=1 on a ~10s loop (exponential backoff), forever.

Root cause

@ff-labs/fff-node (the fff workspace-search integration added in #3099) loads its native binary through the ffi-rs FFI runtime. [email protected] loads its prebuilt addon from a platform-specific package — on Windows x64, @yuuang/[email protected] (an optionalDependency of ffi-rs).

The desktop artifact build (#3109, "Stage fff native binaries in desktop builds") stages the fff binary packages (@ff-labs/fff-bin-*) and adds them to asarUnpack, but does not stage ffi-rs's own native binding. electron-builder reliably keeps direct production deps but prunes platform-gated transitive optional deps in pnpm layouts, so @yuuang/ffi-rs-* is dropped from the package entirely. Confirmed: the installed resources/ (incl. app.asar.unpacked) contains no ffi-rs/@yuuang native packages.

Because the desktop window is gated on backend HTTP readiness (DesktopBackendManager polls /.well-known/t3/environment, then DesktopWindow.handleBackendReady creates the window), a backend that never becomes ready means the window is never created — while the main process stays alive restarting the backend indefinitely. That is exactly why "process running, no window" and "restart doesn't help."

The staging logic omits @yuuang/ffi-rs-* for all platforms, so mac and linux nightlies are very likely affected too (needs confirmation on those platforms).

Fix

Mirror the @ff-labs/fff-bin-* treatment for the FFI binding in scripts/build-desktop-artifact.ts:

  1. Promote the target-triple @yuuang/ffi-rs-{platform}-{arch}[-abi] binding to a direct staged dependency (version resolved from the lockfile, where ffi-rs is pinned).
  2. Add node_modules/@yuuang/ffi-rs-*/**/* to DESKTOP_ASAR_UNPACK so the .node is loadable outside the asar.

A win32-x64 release smoke test that actually boots the backend would have caught this; recommend adding backend-boot coverage to release:smoke / test:desktop-smoke.

References

  • Introduced by #3099 (use fff) + #3109 (stage fff natives)
  • Same backend-crash-loop → no-window failure class as #3038 (different root cause)
  • Related: #2442 (window gated on backend readiness)

akj avatar Jun 17 '26 12:06 akj

This issue was already solved yesterday by a new release if I'm not mistaken

StiensWout avatar Jun 17 '26 17:06 StiensWout

Confirmed MacOS, Linux and Windows latest nightly builds are working for me. Can you give some more info on your setup?

juliusmarminge avatar Jun 18 '26 00:06 juliusmarminge

The failure was tied to nightly build 0.0.28-nightly.20260616.571; follow-up testing confirmed later nightly builds working on macOS, Linux, and Windows. The build-specific regression is no longer current.

This was closed as part of a large repo-wide maintenance sweep. If you think it's still relevant, please reopen.

juliusmarminge avatar Jun 20 '26 01:06 juliusmarminge