mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 14:35:17 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - External adapters are npm packages that the server imports at
startup through `buildExternalAdapters` in the plugin loader
> - Startup recovery waits for the full external adapter load pass
before the server reports healthy
> - If the import of one package never settles, for example because of a
top-level `await` that never resolves, the pass never returns
> - Then startup recovery stays in the `recovering` phase for the life
of the process, and `/health` keeps reporting `starting`
> - This pull request gives each package a wall-clock load budget and
skips a package that goes over it
> - The benefit is that one broken adapter package cannot keep the whole
server from becoming healthy
## Linked Issues or Issue Description
No issue exists.
**What happened?**
After installing an external adapter package whose import never settled,
the server stayed in `starting` on `/health` and never finished startup
recovery.
**What did you expect?**
The server skips the package with a warning and finishes startup.
**Steps to reproduce**
1. Install an external adapter package whose entry module has a
top-level `await new Promise(() => {})`.
2. Start the server.
3. `/health` keeps reporting `starting`.
**Paperclip version**
`master` at the time of this PR.
## What Changed
- `server/src/adapters/plugin-loader.ts`:
- `DEFAULT_EXTERNAL_ADAPTER_LOAD_TIMEOUT_MS` (10 s) and an
`ExternalAdapterLoadTimeoutError`.
- `loadFromRecord` races the package import against the budget. A
package that goes over the budget is skipped with a warning, and the
pass continues with the next package.
- A late failure of a skipped import is consumed, so it does not become
an unhandled rejection.
- A skipped import that finishes later does not write its UI parser to
the cache, so it cannot replace a parser that was loaded or reloaded in
the meantime.
- `buildExternalAdapters` takes an optional `{ timeoutMs }`. The
cloud-managed early return does not change.
- `server/src/__tests__/external-adapter-load-timeout.test.ts`: a
healthy package still loads, the pass returns when a package import
never resolves, and an import that finishes after the budget leaves no
UI parser in the cache.
## Verification
- `cd server && npx vitest run
src/__tests__/external-adapter-load-timeout.test.ts
src/__tests__/plugin-loader-error-retry.test.ts`: passes.
- `pnpm --filter @paperclipai/server typecheck`: passes.
## Risks
- A package that needs more than 10 s to import is now skipped at
startup. That is very slow for an import; a caller can pass a larger
`timeoutMs`.
- The import that went over the budget keeps running in the background,
because a dynamic import cannot be cancelled. Its result, including its
UI parser, is ignored.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, git, test runs). Extended reasoning on.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>