Skip to content

fix(server): issues #115-#118 kick, empty text, SQLite busy - #119

Merged
Cod-e-Codes merged 4 commits into
mainfrom
fix/issues-115-118
Aug 5, 2026
Merged

fix(server): issues #115-#118 kick, empty text, SQLite busy#119
Cod-e-Codes merged 4 commits into
mainfrom
fix/issues-115-118

Conversation

@Cod-e-Codes

@Cod-e-Codes Cod-e-Codes commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #115
Fixes #116
Fixes #117
Fixes #118

Test plan

Black-box against binaries built from this branch (temp server on localhost, raw WebSocket client, SQLite file DB):

  • CI go.yml build + database-smoke green after each commit
  • Self-kick rejected with System You cannot kick yourself.; connection stays open; reconnect works (no 24h ban)
  • Self-ban rejected with System You cannot ban yourself.; reconnect works (not permanently banned)
  • Offline kick returns user is not connected (not success); target can still connect (no ban)
  • Online kick reports success, victim disconnects, reconnect gets close 1008 You are banned from this server
  • Empty and whitespace-only plaintext rejected with Message not sent: empty content; Encrypted opaque content still accepted
  • Concurrent load 20 clients x 10 messages: 200/200 writes, 200/200 rows persisted, 0 SQLITE_BUSY / insert-lock errors in server log

Self-targeting :kick/:ban disconnected the admin and wrote a 24h ban
with no reply. KickUser/BanUser now return errors so chat, TUI, and web
claim success only on nil.
Kick requires an active connection; offline targets return ErrKickNotConnected
without tempKicks or ban_history. BanUser remains offline-capable.
Unencrypted empty or whitespace-only content is dropped with a System
reply and never persisted; encrypted opaque payloads stay unchecked.
Per-connection modernc DSN pragmas and MaxOpenConns(1) replace one-shot
PRAGMA Exec so pooled writers no longer fail with SQLITE_BUSY under load.
@Cod-e-Codes Cod-e-Codes added bug Something isn't working documentation Improvements or additions to documentation go Pull requests that update go code labels Aug 4, 2026
@Cod-e-Codes

Cod-e-Codes commented Aug 4, 2026

Copy link
Copy Markdown
Owner Author

I re-checked #118 against the current implementation and primary docs.

Verdict: the current #118 fix is sufficient.

The fix applies SQLite pragmas through the modernc.org/sqlite DSN before opening the DB, including _busy_timeout, _journal_mode=WAL, _synchronous=NORMAL, and _pragma values. modernc.org/sqlite v1.55.0 documents those DSN keys and applies _busy_timeout early. The code then verifies busy_timeout, verifies WAL for file-backed DBs, skips WAL verification for memory DSNs, and limits SQLite to a single open/idle connection to serialize same-process writes.

The in-repo proof is TestInitDBSQLiteConcurrentInserts: it initializes SQLite through InitDB, creates the schema, runs 8 goroutines x 20 InsertMessage calls, asserts no insert errors, and checks COUNT(*) == 160.

The test proves the database-layer same-process concurrent insert path. It does not claim to be a full WebSocket fan-in reproduction or an external-process lock test.

@Cod-e-Codes
Cod-e-Codes merged commit b0c53a7 into main Aug 5, 2026
6 checks passed
@Cod-e-Codes
Cod-e-Codes deleted the fix/issues-115-118 branch August 5, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation go Pull requests that update go code

Projects

None yet

1 participant