Skip to content

Fix records/query auth mismatch and add bounded shutdown - #77

Merged
cuibonobo merged 1 commit into
mainfrom
claude/issue-49-plan-9ruo3i
Aug 21, 2026
Merged

Fix records/query auth mismatch and add bounded shutdown#77
cuibonobo merged 1 commit into
mainfrom
claude/issue-49-plan-9ruo3i

Conversation

@cuibonobo

Copy link
Copy Markdown
Member

Summary

Closes the two items still open in #49 (the other four were already fixed by prior work, per the issue's own follow-up comment):

  • POST /records/query auth doc mismatch: the route required auth while docs/api.md listed it as Optional. Aligned code to the docs (removed requireAuth()) rather than the reverse, since GET /records is already anonymous-friendly and /records/query is documented as a superset of the same query surface. Pinned with a test mirroring the existing GET /records anonymous-query test. Updated docs/deployment.md's two mentions of anonymous-reachable read routes to include POST /records/query.
  • Unbounded shutdown: shutdown() waited on server.close() with no deadline, so a client holding a keep-alive connection open could block it indefinitely. Added a configurable SHUTDOWN_TIMEOUT_MS (default 10s, same pattern as QUERY_TIMEOUT_MS), after which open connections are forced closed via closeAllConnections() so cleanup still runs. Also added stack.flush() to the fatal-startup-error path, guarded for the case where the crash happens before the stack context exists. The shutdown sequence is extracted into src/shutdown.ts so it's unit-testable without touching process.exit.

Test plan

  • pnpm test — 336 tests pass, including new coverage for anonymous POST /records/query, SHUTDOWN_TIMEOUT_MS config validation, and the shutdown handler's timeout/no-timeout/no-closeAllConnections paths
  • pnpm typecheck
  • pnpm lint
  • pnpm format:check

Generated by Claude Code

POST /records/query required auth while docs said Optional; align to
GET /records's anonymous-friendly behavior (it's a superset of the
same query surface) and pin it with a test.

shutdown() previously waited on server.close() indefinitely, so a
client holding a keep-alive connection open could block it forever.
Add a configurable SHUTDOWN_TIMEOUT_MS deadline, after which open
connections are forced closed so cleanup still runs, and flush the
stack on the fatal-startup-error path too. The shutdown sequence is
extracted into its own module so it's unit-testable without invoking
process.exit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RgFKoffjrpKGCdEYX551LY
@cuibonobo
cuibonobo merged commit ffd3554 into main Aug 21, 2026
4 checks passed
@cuibonobo
cuibonobo deleted the claude/issue-49-plan-9ruo3i branch August 21, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants