Skip to content

fix(server): keep slow searches alive - #60

Merged
andrei-hasna merged 1 commit into
mainfrom
fix/471bef3b-sessions-search-502
Aug 11, 2026
Merged

fix(server): keep slow searches alive#60
andrei-hasna merged 1 commit into
mainfrom
fix/471bef3b-sessions-search-502

Conversation

@andrei-hasna

@andrei-hasna andrei-hasna commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • configure Bun.serve with a 60-second idle timeout instead of inheriting Bun's 10-second default
  • allow HASNA_SESSIONS_IDLE_TIMEOUT_SECONDS overrides from 0 through 255 seconds
  • document the server setting and add a regression around the exact server configuration

Root cause

ALB access logs for the reported window show /v1/search/content succeeding when target processing stayed below eight seconds, then returning elb_status=502 target_status=- response_processing=-1 when target processing crossed roughly 10–11 seconds. The ECS task remained healthy and the same endpoint recovered without task replacement.

createSessionsServer did not set Bun.serve.idleTimeout. Bun's 10-second default applies to in-flight handlers that have not emitted response bytes, so slow or pool-contention-delayed database searches had their connection reset before the handler returned JSON.

Todos: 471bef3b-7ed4-4758-b9eb-06c485dc6a03 (OPE25-00018)

Validation

  • regression before fix: Expected: 60, Received: undefined
  • bun test test/server.test.ts: 10 passed, 0 failed
  • bun test test/server.test.ts test/serve-v1.test.ts test/mcp-http.test.ts: 23 passed, 0 failed
  • bun run typecheck: exit 0
  • bun run build: exit 0
  • full bun test: one unrelated watcher timeout in test/codewith-source.test.ts; exact file rerun passed 7/7, including the timed-out case in 1.13 seconds
  • staged secret scan: 0 findings across 3 changed files
  • committed-diff secret scan: 0 findings

Hosted path

The three originally failing commands now return [] with exit 0 on the current production service. The candidate itself is not deployed by this PR, so a concurrency/slow-query hosted verification remains a post-deployment gate.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Configure Bun server idle timeouts so database-backed search requests can complete beyond Bun default 10 seconds without resetting the ALB connection.

Agent: agent-ea
@andrei-hasna

Copy link
Copy Markdown
Contributor Author

[REVIEW] GO — #60 @ 5a7e929 — lens: correctness+security+gates, reviewer unresolved-account002 (1 of 1)

Reviewed the exact candidate against fetched base 97d45dfffad9e7cb819206b47d1660d5313e137d.

What I read:

  • git log --oneline origin/main..HEAD — exit 0; one commit: 5a7e929 fix(server): keep slow searches alive.
  • git diff origin/main...HEAD --stat — exit 0; 3 files changed, 51 insertions, 1 deletion.
  • Full diff and surrounding source for src/server/app.ts, src/server/index.ts, and test/server.test.ts.
  • Reachable callers/coverage in src/mcp/index.ts, src/server.ts, test/mcp-http.test.ts, and test/serve-v1.test.ts.
  • Installed Bun 1.3.14 server types/docs for idleTimeout: seconds, default 10, maximum 255, and 0 disables the timeout.

Commands and gates:

  • bun installbun install exit=0; setup only, 117 packages installed.
  • bun run typecheckbun run typecheck exit=0; 0 diagnostics.
  • bun run testbun run test exit=0; 381 pass, 0 fail, 1803 expect() calls, 44 files.

Blocking P0/P1 findings: none. The new environment value is validated before server startup, invalid or out-of-range values fail closed, and the default is passed through the shared REST/MCP HTTP server factory without changing authentication or data-handling paths.

Non-blocking follow-ups: none.

@andrei-hasna
andrei-hasna merged commit 834efa0 into main Aug 11, 2026
2 checks passed
@andrei-hasna
andrei-hasna deleted the fix/471bef3b-sessions-search-502 branch August 11, 2026 11:31
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.

1 participant