Skip to content

fix(pi-fff): install fff-bun so bun runtimes can load the SDK (#689) - #694

Merged
dmtrKovalenko merged 1 commit into
mainfrom
triage-bot/issue-689
Jul 20, 2026
Merged

dmtrKovalenko merged 1 commit into
mainfrom
triage-bot/issue-689

Conversation

@gustav-fff

Copy link
Copy Markdown
Collaborator

Closes #689

Root cause

PR #669 (commit d1dac82) added a runtime bun/node switch in packages/pi-fff/src/sdk.ts:26 that dynamically imports @ff-labs/fff-bun when running under bun. The same PR declared @ff-labs/fff-bun as an optional peer dependency in packages/pi-fff/package.json:48-55. Package managers do not install optional peers by default, so pi install npm:@ff-labs/pi-fff on a bun-only host produces a node_modules tree containing @ff-labs/fff-node but not @ff-labs/fff-bun, and pi crashes at session_start with Cannot find module '@ff-labs/fff-bun'.

Fix

Promote @ff-labs/fff-bun from optional peer to a regular dependency alongside @ff-labs/fff-node in packages/pi-fff/package.json. Bundle-size cost is minor — both SDKs are thin TS shims over the same optional native @ff-labs/fff-bin-* binaries — and this guarantees the dynamic import in sdk.ts always resolves regardless of runtime or which installer pi uses. bun.lock regenerated accordingly.

Steps to reproduce

Reproduce on origin/main (pre-fix) on any host with bun and no global node:

bun i -g @earendil-works/pi-coding-agent
pi install npm:@ff-labs/pi-fff

# Confirm the missing dep:
grep -c '"@ff-labs/fff-bun"' ~/.pi/agent/npm/bun.lock   # → 0

pi

Expected: pi starts, session_start succeeds, ffgrep/fffind tools available.

Actual (pre-fix):

Error: FFF init failed: ResolveMessage: Cannot find module '@ff-labs/fff-bun' from '/home/<user>/.pi/agent/npm/node_modules/@ff-labs/pi-fff/src/sdk.ts'

Confirmed by three independent reporters (Debian, mise, Windows/scoop) in issue #689, all sharing bun as the runtime.

How verified

Simulated a fresh install of the fixed package into an empty project against a bun-only host:

mkdir /tmp/pi-fff-test && cd /tmp/pi-fff-test
cat > package.json <<'JSON'
{ "dependencies": { "@ff-labs/pi-fff": "file:.../packages/pi-fff" } }
JSON
bun install
ls node_modules/@ff-labs/
# → fff-bin-darwin-arm64  fff-bun  fff-node  pi-fff   (fff-bun now present)

Also ran:

cd packages/fff-node && bun run build   # OK
cd packages/pi-fff   && bun run typecheck # OK, no errors

Automated triage via Gustav. Honk-Honk 🪿

PR #669 made sdk.ts dynamically import @ff-labs/fff-bun when running under
bun, but only added it as an optional peer dependency. Package managers do
not install optional peers by default, so `pi install npm:@ff-labs/pi-fff`
on a bun-only host produced a node_modules tree without @ff-labs/fff-bun
and pi crashed at session_start with "Cannot find module '@ff-labs/fff-bun'".

Promote both SDKs to regular deps. Bundle size cost is minor (SDKs are TS
shims over the same optional native bins) and this guarantees the dynamic
import in sdk.ts always resolves regardless of runtime or installer.

Closes #689
@dmtrKovalenko

Copy link
Copy Markdown
Owner

@gustav-fff why it is failed?

@gustav-fff

Copy link
Copy Markdown
Collaborator Author

[triage-bot] CI status: 32 checks green, e2e (ubuntu-latest) failed at the Run node tests step (https://github.com/dmtrKovalenko/fff/actions/runs/29762462344/job/88420178528). That step runs @ff-labs/fff-node e2e tests, which this PR does not touch — the only diff is packages/pi-fff/package.json moving @ff-labs/fff-bun from optional peer to regular dep, plus the regenerated bun.lock. Failing log not yet available (run reported "still in progress" when polled). Time-boxed; leaving to maintainer to determine whether pre-existing on main or CI-flake.

Honk-Honk 🪿

@dmtrKovalenko
dmtrKovalenko merged commit 16a666b into main Jul 20, 2026
55 of 56 checks passed
@gustav-fff

Copy link
Copy Markdown
Collaborator Author

[triage-bot] DIRECTED: Flaky watcher race, unrelated to this PR. Attempt 2 passed and all checks are now green (gh pr checks 694 shows every check pass/skip).

Failing test on attempt 1: fff-node watch > process exits naturally after unsubscribing (trampoline released) at packages/fff-node/test/watch.mjs:233. Verbatim error from the child process:

file:///home/runner/work/fff/fff/packages/fff-node/[eval1]:14
      if (!sub.ok) throw new Error(sub.error);
                         ^
Error: Failed to subscribe: File system watcher is not ready

Race in the test itself: finder.waitForScan(10_000) returns, but the watcher trampoline is not yet armed when finder.watch(...) is called on the next line. Nothing in this PR touches fff-node or the watcher — the diff is packages/pi-fff/package.json promoting @ff-labs/fff-bun from optional peer to regular dep, plus regenerated bun.lock. Same test passed on alpine-musl, macos-latest, windows-latest on the same attempt, and on ubuntu-latest on the rerun — classic timing flake introduced by #674 (feat(sdk): Expose file watcher).

Honk-Honk 🪿

abhijit-s pushed a commit to abhijit-s/fff that referenced this pull request Jul 21, 2026
Upstream 0.10.1 batch (5 commits): pi-fff fixes (install fff-bun dmtrKovalenko#689/dmtrKovalenko#694,
Windows cross-volume paths dmtrKovalenko#684), node/bun Android arm64 Termux support (dmtrKovalenko#695),
and the 0.10.1 release/version bumps. No Rust source changes reach the fork —
all JS-SDK/packaging/CI.

Conflicts (config only, no code):
- All crate Cargo.toml + workspace: take ours (fork stays 0.17.1; upstream's
  0.10.1 is its own release line). fff-mcp keeps daemon deps (fff-ipc/dirs/libc).
- install-mcp.sh: ours (fork installs from HEAD/source, not upstream release-pin).
- release.yaml: ours — keep the Android C-FFI matrix entry commented, consistent
  with the fork's policy of disabling non-macOS C builds to keep CI lean.
- Cargo.lock: ours (workspace unchanged vs f5db5c1).

Daemon rust verified intact (server.rs proxy path present); build-daemon green.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: pi-fff fails to load because of ' Cannot find module '@ff-labs/fff-bun''

2 participants