Skip to content

dev: the auth slot double-opens the auth PGlite data dir — the host marks it permanent and the composed SSR plane 500s on every route #1259

Done

Description

@efizzybot

Found while verifying #1247–#1249 (PR #1258) in a fresh worktree. Reproduces on the pristine base (verified via git stash → same failures), so it is not caused by that branch. Every pnpm run dev boot in this worktree fails the auth plugin — .bos/logs/ holds five boot logs, none green, and no successful dev boot has ever run here.

Repro

Fresh clone/worktree → pnpm run setup → pnpm run dev → the boot completes but auth fails:

curl -s localhost:3000/health | jq .status,.auth
# "ready"  /  "unavailable"

Observed chain (dev-2026-12-02T20-37-21-15636.log and the four earlier sessions)

  1. One dev session opens the auth PGlite data dir twice. The auth plugin's every-plugin dev child opens plugins/auth/.bos/db/auth and becomes ready — ✅ Plugin ready: @everything-dev/auth-plugin — while the host's in-process auth slot load opens the same dir and hits the kernel lock:

    Plugin @everything-dev/auth-plugin failed during initialize-plugin:
    PluginRuntimeError: DatabaseError [stage=driver]: [db] PGlite data dir ".../plugins/auth/.bos/db/auth"
    is locked by another process (.../.pglite-lock) — held by pid <own-session's auth dev child>
    

    The lock holder is always the session's own auth dev child (ps -p <pid> → every-plugin.mjs dev, parented by the bos dev session pid). So this is not cross-session contention — the dev topology composes two live openers of one data dir within a single session. ADR 0044's preflight refuses same-dir composition at boot, but this composition happens at runtime and is not preflighted.

  2. The host marks the failure permanent and never recovers. Failed to load plugin (initialize-plugin) — permanent, /health reports auth: unavailable for the rest of the session — even though the auth dev child is up, healthy (:3002 answers 200), and its initialize succeeded on its own retry. There is no adopt/retry path from "dev child ready" to "host slot loaded". Also seen on attempt 1 of the child's own boot: a transient DatabaseError [stage=load]: fetch failed: read ECONNRESET (the api plugin hits the same during the 12-plugin build storm) — the child retries, the host does not.

  3. The composed SSR plane 500s on every route while auth is down. In the sessions where the host reached SSR composition, the composed tree includes the auth plugin's routeConfig, and loading its SSR remote fails:

    [SSR] Ui routeConfig _everything_dev_auth_plugin failed: Failed to load _everything_dev_auth_plugin
    from http://127.0.0.1:<port>/ssr/remoteEntry.server.js: The getter for the shared module is not a function.
    This may be caused by setting "shared.import: false" without the host providing the corresponding lib. #RUNTIME-012
    [SSR] <digest> Manifest composition failed for /docs
    

    / and /about — core routes with no auth code — 500 with SSR composition failed. One plugin slot's SSR failure cascades to the whole plane instead of degrading that plugin only (compare the runtime load's warn-and-skip contract for unavailable plugin ui sources).

Impact

What this is not

  • Not the kernel flock itself (ADR 0044) — the lock works as designed and correctly refused a corrupting double-open.
  • Not the transient ECONNRESET in isolation — the child's retry handles it; the bug is the topology plus the host's permanent-no-retry handling.

Done when

  1. One dev session never opens the auth PGlite dir from both the plugin dev child and the host's in-process auth slot (either the host proxies auth to the dev child, or the dev child serves the remote without holding the DB — whichever matches the ADR 0051 dev-adopt intent; the preflight should also fail loud on this composition instead of the runtime driver error).
  2. A transient initialize failure no longer strands the session: the host retries the auth slot load (or the dev adopt recovers it) once the dev child reports ready, instead of retryable: false forever.
  3. One plugin slot's SSR compose failure degrades that plugin's routes only — core routes and composed non-auth routes keep rendering.
  4. A fresh worktree boots pnpm run dev green end to end (auth available, / and /about SSR 200, /docs composed) — this is the reproduction environment.

Activity

  1. added
    needs-triage
    on Dec 2, 2026
  2. efizzybot commented on Dec 2, 2026

    @efizzybot
    CollaboratorAuthor

    Root cause located and the topology half is fixed in PR #1261 (2026-12-02) — cutting the issue down to the remainder per the partial-fix pattern:

    What landed (PR #1261, two commits):

    • Done-when 1 — the auth dev child no longer opens the seeded dir at all: the session now sets AUTH_DATABASE_URL=pglite::memory: on the auth child's env when the zero-config seed is active, so the host's in-process auth slot is the session's sole opener (ADR 0051's division: the child is the artifact server). The preflight grew an opener check (pgliteOpenerCollisions) that fails bos dev loud with opener labels when any composition would put two live openers on one file-backed pglite dir — the one-secret-two-processes shape the secrets-per-dir check couldn't see (ADR 0044 amendment).
    • A second, distinct defect found while verifying done-when 4: with SSR intent the ui builds resolved better-near-auth to its TS source and the SSR container died on Cannot find module './store.js' — web/node environments lacked the extensionAlias the plugin backend build already sets. That failure degraded boot compose to a 503 on every route and failed host readiness. Fixed in the same PR.

    Verified in a fresh worktree (the repro environment): ◉ APP READY, /health → ready / auth: ready, / + /about + /docs SSR 200 — done-when 4 green on this PR.

    Remaining on this issue:

    • Done-when 2 — a transient initialize failure still strands the slot: forkDevPluginAdopt requires captured load args (ADR 0051 amendment, line 97 names the gap); nothing re-runs a boot-failed slot load once the dev child reports ready.
    • Done-when 3 — one local plugin ui source's SSR compose failure still fails the whole plane (ssr-render 500s every route). The fix shape is to mirror the backend plane's per-plugin degrade contract in the compose plane; it amends ADR 0063's loud-500 stance for the plugin-slot scope (core stays loud), so it wants its own PR.
  3. efizzybot commented on Dec 2, 2026

    @efizzybot
    CollaboratorAuthor

    The remainder is now also up as stacked PRs on #1261:

    With #1261 (topology + the ui SSR build fix) landing first, all four done-when items are covered.

  4. efizzybot commented on Dec 2, 2026

    @efizzybot
    CollaboratorAuthor

    All four done-when items are landed on main, each verified in the fresh-worktree repro environment:

    Closing with credit to @efizzybot for the issue's precise failure-chain analysis — the repro environment and the observed chain made every fix targetable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions