Skip to content

Preserve the SQLite result code on standalone server startup failure #65547

Open

Description

@xxchan

OpenCode 2.2.7 on Windows occasionally exits before the ACP client receives the standalone ready line. In three original CI artifacts, the child’s native log recorded “Failed to configure database” and “disk I/O error”. The client printed only “Standalone server exited before reporting readiness”. This prevents distinguishing a WAL shared-memory operation from a read, write or other I/O failure.

The original artifact IDs are 14672283929, 14687429652 and 14703809976. Our host starts a session on the same data directory while another is shutting down. This overlap was common in passing runs too, so the traces do not establish it as the cause. The same “disk I/O error” text also appeared once on Windows with 1.19.5, before the 2.x driver.

Where the diagnostic loses detail

The November 21 source check covered the latest npm release 2.3.2 (c0ad18b) and the default development branch (ba5bbef). Both retain the same startup failure logging and generic readiness error as the observed 2.2.7 build. The Windows failure itself was measured on 2.2.7. In all three source revisions, bun.lock pins Effect and @⁠effect/sql-sqlite-bun to 4.1.0. The driver calls db.run for busy_timeout and WAL setup with the same configure-database error label. It passes the original Bun exception to classifySqliteError. For an IOERR, Effect constructs UnknownError with the original exception in reason.cause, and SqlError exposes the reason as its cause. The classifier retains the exception in memory. Driver source in the published package, Effect classifier

OpenCode logs a failed CLI process with the Effect cause in the message object. Its file logger flattens plain objects and calls Formatter.format on other values. The cause and Fail reason stringify their contained reasons and errors. Formatter handles errors through their string representation and nested cause. That path does not enumerate separate SQLiteError.code or errno properties. The client’s standalone launcher also ignores the child’s stderr unless OPENCODE_PRINT_LOGS is enabled, and an EOF before the ready line yields the generic message. CLI failure logging, file logger, standalone launcher, Effect formatter

Please record the connection-setup operation name and any available SQLiteError.code and numeric errno as structured fields before formatting. Where available, include the database file role (main, WAL, or SHM). A missing role can remain unknown. For the generic readiness failure, please include a bounded tail of child stderr or the path to the child's native log. That would also help diagnose startup failures unrelated to SQLite. Current development launcher

One possible regression test would pass an exception with “disk I/O error” as its message and a separate extended-code property, then check that the property survives logging. The captured runs contain no evidence for a particular extended code.

Drafted with AI assistance from OAR Windows CI artifacts and source inspection.


Agent Cindy for @xxchan via Stamp (grant cgr_0a427a0749428a5c521774a30edf08b7)

Activity

  1. opencodejr commented on Nov 22, 2026

    @opencodejr
    Contributor

    Thanks for the detailed write-up and the source tracing. Your request: when the standalone server fails during SQLite connection setup, log the operation, the SQLite error code, the errno and the file role as structured fields. And when the server exits before reporting readiness, show the end of the child's stderr or the path to its log instead of only the generic message.

    The current code matches what you describe:

    • The standalone launcher sets the child's stderr to "ignore" unless OPENCODE_PRINT_LOGS=1.
    • If stdout closes before the ready line, the only error is Standalone server exited before reporting readiness.
    • The file logger turns only plain objects into separate fields. Other values, such as errors, go through Formatter.format.

    Until this changes, setting OPENCODE_PRINT_LOGS=1 in the environment of the process that starts opencode acp should pass the child's stderr through, which may help capture more from the CI runs.

    Maintainers will consider the request. I can't promise when, or whether, it will be picked up.

    Related issues:

  2. added
    area/service
    type/feature
    version/v2
    on Nov 22, 2026
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

    area/serviceplatform/windowstype/featureversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions