Skip to content

fix(db): harden sqlite3 signal handling#17116

Open
tobwen wants to merge 1 commit intoanomalyco:devfrom
tobwen:fix/harden-sqlite3-signal-handling
Open

fix(db): harden sqlite3 signal handling#17116
tobwen wants to merge 1 commit intoanomalyco:devfrom
tobwen:fix/harden-sqlite3-signal-handling

Conversation

@tobwen
Copy link
Contributor

@tobwen tobwen commented Mar 12, 2026

Issue for this PR

Closes #17114

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This hardens opencode db when it launches the interactive sqlite3 shell.

The user-visible bug was that after leaving opencode db with Ctrl-C, the terminal could come back in a broken state and echo later input character-by-character on separate lines instead of returning cleanly to the shell.

This change fixes that by tightening the interactive sqlite3 signal and exit handling. It also closes the Bun SQLite handle in query mode with finally, handles sqlite3 spawn failures explicitly, preserves non-zero child exit codes, and avoids the global SIGHUP handler collapsing signal-derived exit status.

In short: the command now behaves much more predictably when sqlite3 is interrupted or terminated.

How did you verify your code works?

  • Ran bun typecheck in packages/opencode
  • Ran bun run build in packages/opencode
  • Reproduced the issue by exiting opencode db with Ctrl-C and confirmed the shell returned cleanly instead of echoing later input character-by-character

Screenshots / recordings

Before

image

After

image

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: sqlite3 signal handling needs hardening

1 participant