Skip to content

Ship and verify the packaged host plugin worker - #1790

Merged
ymichael merged 2 commits into
mainfrom
bb/fix-keep-awake-worker-exit-thr_hh3dtrmbwv
Aug 18, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/fix-keep-awake-worker-exit-thr_hh3dtrmbwv

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Packaged bb-app daemons fail every host plugin call with host plugin worker exited (1). Their stderr reports that neither the compiled worker nor its TypeScript development fallback exists in the installed package.

defaultWorkerEntryPath() looked for plugin-host-worker.js beside daemon-bundle.mjs and fell back to the .ts source. The published package contained neither: the bundle manifest had no worker target, and the bb-app package whitelist only shipped the .mjs bundles.

The Keep Awake-specific retry mitigation was split out and merged in #1792. This PR now contains only the general packaging fix and its release-level coverage.

Changes

  • Add a self-contained bb-plugin-host-worker.mjs bundle.
  • Resolve the packaged .mjs worker first while retaining compiled-development and source-development fallbacks.
  • Ship the worker in bb-app and require it during launcher artifact validation.
  • Assert that the npm package whitelist includes the worker.
  • Exercise the packed worker directly with the packed Keep Awake host artifact.
  • Verify worker startup in the full packaged stack and on two independently enrolled packaged daemons.

No daemon wire contract changed, so no HOST_DAEMON_PROTOCOL_VERSION bump is needed.

Verification

  • turbo run typecheck --filter=@bb/host-daemon --filter=bb-app
  • turbo run test --filter=@bb/host-daemon --filter=bb-app --force (583 host-daemon tests and 65 bb-app tests)
  • turbo run smoke:tarball --filter=bb-app --force (direct packed worker, full stack, and two-daemon enrollment)
  • Prettier, JavaScript syntax check, and git diff --check

AGENT GENERATED: by GPT-5

@ymichael
ymichael marked this pull request as ready for review August 18, 2026 18:22
ymichael pushed a commit that referenced this pull request Aug 18, 2026
## Problem

Keep Awake's `experimental_onWorkerExit` handler called
`requestReconcile()`, which forces an immediate pass and skips the retry
backoff. When a host worker crashes on start (see #1790 for the
packaging cause), the server loops every ~80ms:

```
Keep Awake host worker exited unexpectedly on host host_...; retrying
Could not reconcile Keep Awake on host host_...: host plugin worker exited (1)
```

One log file collected 60k+ of these lines.

## Change

- `plugins/keep-awake/server.ts`: worker exits now request a *retry*,
which waits for the exponential backoff (1s → 2s → … → 30s cap).
Configuration changes and host connects still reconcile immediately.
- `plugins/keep-awake/server.test.ts`: fake-timer tests for the delayed
retry and the crash-loop backoff. The crash-loop test spins forever on
the old code.

This is the plugin-side half of #1790, split out so it can land now. The
packaging fix (ship `bb-plugin-host-worker.mjs`) stays in #1790.

## Verification

`turbo run test typecheck --filter=bb-plugin-keep-awake` passes.

> AGENT GENERATED: by Claude Opus 5

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <[email protected]>
SawyerHood and others added 2 commits August 18, 2026 11:29
Bundle, package, resolve, and validate the host plugin worker in bb-app releases.
@ymichael
ymichael force-pushed the bb/fix-keep-awake-worker-exit-thr_hh3dtrmbwv branch from 5320b8f to c20e077 Compare August 18, 2026 18:29
@ymichael ymichael changed the title Ship the plugin host worker bundle and back off Keep Awake worker retries Ship and verify the packaged host plugin worker Aug 18, 2026
@ymichael
ymichael merged commit 007fb19 into main Aug 18, 2026
10 checks passed
@ymichael
ymichael deleted the bb/fix-keep-awake-worker-exit-thr_hh3dtrmbwv branch August 18, 2026 18:40
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.

2 participants