Repository navigation
Conversation
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
There was a problem hiding this comment.
Works as described. With a directory as the database path, the base's acp printed only Standalone server exited before reporting readiness. With this PR, the child's stderr tail follows that line. Running serve --stdio directly, the log now has operation=open role=main code=SQLITE_CANTOPEN errno=14. The new cli and core tests pass. I couldn't run the typecheck scripts here: they call bun check, which this environment's bun 1.4.2 doesn't have.
Public API: unchanged. The launcher now always reads the child's stderr instead of ignoring it, and OPENCODE_PRINT_LOGS=1 still forwards it live.
Two small things are worth fixing, both inline: the new role field collides with the logger's existing role=server annotation, and on node:sqlite code is always ERR_SQLITE_ERROR.
| const errno = resultCode(driver) | ||
| return Effect.logError("Failed to configure database", { | ||
| operation, | ||
| ...(role === undefined ? {} : { role }), |
There was a problem hiding this comment.
The server's logger already tags every line with role=server, so the log line ends up with two role keys. Running serve against a bad path gives ... operation=open role=main code=SQLITE_CANTOPEN errno=14 error="..." role=server. Anything that parses these as key/value pairs will keep only one of them. A distinct key such as file: "main" (or databaseFile) would avoid the clash. The test asserts role and would need updating to match.
| Option.map((error) => error.errcode), | ||
| Option.getOrUndefined, | ||
| ) | ||
|
|
There was a problem hiding this comment.
code is a literal ERR_SQLITE_ERROR in this schema, so on node:sqlite errorCode always logs that fixed Node marker. That doesn't tell you anything the errno field doesn't already. node:sqlite errors also carry errstr (SQLite's text for the result code). Decoding errstr, or leaving errorCode undefined here like workerd does, would avoid a misleading code field.
Tag the database file under `file` so it does not collide with the server logger's `role=server` annotation, and report node:sqlite's `errstr` rather than its constant `ERR_SQLITE_ERROR` marker.
416267e to
c6814a4
Compare
|
Both points fixed in c6814a4:
Core tests still pass (3/3), full |
|
Thanks. I checked c6814a4 and both points are addressed. The database file is now logged as |
There was a problem hiding this comment.
Both earlier points are fixed. The database file is now logged as file, which I confirmed by running serve against a bad path: operation=open file=main code=SQLITE_CANTOPEN errno=14. On node:sqlite, errorCode now returns errstr. On Node 24, node:sqlite errors carry errcode and errstr together, so resultCode is unaffected. The core database and storage-failure tests pass. Public API unchanged. Nothing new to raise.
Issue for this PR
Closes #65547
Type of change
What does this PR do?
When SQLite startup fails, the failure reached the log as a bare defect: the formatter loses
SQLiteError.code/errno, and the standalone launcher discarded the child's stderr, so the generic "Standalone server exited before reporting readiness" was all a user saw.Each database setup step now logs its operation name, the file role where the step determines it (
mainfor open/migration,walforjournal_mode), and the driver'sSQLiteError.codeand numericerrno. The open is logged by tapping the cause of the providedsqliteLayer, because the driver dies insideLayer.orDieand the layer'sCauseis the only place that still sees theSqlError. Bun surfacesSQLiteError.code/.errno; node:sqlite surfaceserrcodeplus itsERR_SQLITE_ERRORmarker; the workerd driver has no result-code shape and logs nothing extra.The launcher always pipes child stderr, keeps the last 8KiB, and appends it to the readiness failure.
OPENCODE_PRINT_LOGS=1still forwards the stream live. The readiness failure waits for the stderr drain to finish, but only in the interruptible region: anensuringawait there deadlocked scope close with a live child, since finalizers run sequentially and the stderr drain's own finalizer runs later.How did you verify your code works?
bun run checkpasses (36/36 turbo tasks: lint + typecheck across the monorepo).Logger.formatStructuredon a real open failure (operation: "open", role: "main", code: "SQLITE_CANTOPEN", errno: 14).bun testpasses forpackages/core/test/database.test.ts,packages/core/test/storage-failure.test.ts, andpackages/cli/test/standalone-stderr.test.ts.Checklist
Added by the opencode bot (AI-generated).
Related: #55583, #59189