test: the server error handlers' log record, console silence and server.ts branches

RA
2d ago
+195-0

Issue for this PR

Closes #1847

Type of change

  • Tests only

What does this PR do?

Adds the tests the review of #1788 listed as missing for the server's Hono error handlers, in a new test file. No source changes. The tests pin that:

  • an unknown error's opencode.log record carries its stack frames and its nested cause;
  • with the print-logs flags unset, the handlers print nothing about an unknown error to the console or the standard streams;
  • when opencode.log can't be opened, the response still goes out: 500 with the fixed message and a ref;
  • through the full server, server.ts answers an unknown error (a remote config whose body isn't JSON) with the fixed message and a ref recorded in opencode.log, and a busy session with 400 and its message.

Limits:

  • The busy test makes the session busy with a sleep in its shell, so it's skipped on Windows.
  • The unopenable-log test stands a folder where opencode.log goes for the length of the test and puts the file back after.
  • The print checks watch every console method and both standard streams' write. A write through Bun.stdout/Bun.stderr or straight to the file descriptors isn't seen.

How did you verify your code works?

  • Each test fails when its behaviour breaks: recording only the message fails the log-record test; printing the error fails the print test (both handlers), and printing it from server.ts without its ref fails the full-server unknown case; dropping the log write's catch fails the unopenable-log test; sending the error's text from server.ts fails the full-server unknown case; removing its busy branch fails the busy case.
  • Local (Linux): the 5 tests pass; typecheck clean.

Cost side effects

None.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • I checked for cost side effects (model calls, queries or cloud resources that grow with user data) and described them, or wrote "none"

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01BXxzvt5gnJKUdaiAK5SupM

Summary by CodeRabbit

  • Tests
    • Added coverage for server error responses, including how unexpected failures are reported and logged, and how busy sessions are handled.
    • Added checks for responses when error logging is unavailable, and for keeping detailed error information out of client-facing messages and console output.