Skip to content

Fix server crashes, add timeouts, graceful shutdown, and fix Dockerfile#20

Merged
pareshpawar merged 2 commits intomainfrom
claude/code-review-improvements-NFBIo
Apr 15, 2026
Merged

Fix server crashes, add timeouts, graceful shutdown, and fix Dockerfile#20
pareshpawar merged 2 commits intomainfrom
claude/code-review-improvements-NFBIo

Conversation

@pareshpawar
Copy link
Copy Markdown
Owner

Bug fixes:

  • Remove check() function that called log.Fatal() in request handlers,
    crashing the entire server on any error (e.g. missing template file)
  • Fix unsafe type assertion in GetMyOutboundIP() that could panic
  • Return errors from GetMyOutboundIP() instead of calling log.Fatal()

Performance:

  • Cache outbound IP at startup instead of dialing UDP on every request
  • Parse HTML template once at startup instead of on every request

Reliability:

  • Add read/write/idle timeouts to HTTP server to prevent slow-client attacks
  • Add graceful shutdown on SIGINT/SIGTERM with 15s drain timeout
  • Deduplicate color-coded request logging into logRequest() helper

Dockerfile fixes:

  • Fix build command to compile entire module (was missing utils package)
  • Fix EXPOSE port from 8000 to 8081 to match actual listen port
  • Copy html/ directory into runtime image for /html/ endpoint
  • Set WORKDIR to / so relative paths resolve correctly

Also bumps Go version from 1.20 to 1.21 in go.mod.

https://claude.ai/code/session_01GkWCj6JKLSqEtnkBpPoFBL

claude added 2 commits April 4, 2026 16:46
Bug fixes:
- Remove check() function that called log.Fatal() in request handlers,
  crashing the entire server on any error (e.g. missing template file)
- Fix unsafe type assertion in GetMyOutboundIP() that could panic
- Return errors from GetMyOutboundIP() instead of calling log.Fatal()

Performance:
- Cache outbound IP at startup instead of dialing UDP on every request
- Parse HTML template once at startup instead of on every request

Reliability:
- Add read/write/idle timeouts to HTTP server to prevent slow-client attacks
- Add graceful shutdown on SIGINT/SIGTERM with 15s drain timeout
- Deduplicate color-coded request logging into logRequest() helper

Dockerfile fixes:
- Fix build command to compile entire module (was missing utils package)
- Fix EXPOSE port from 8000 to 8081 to match actual listen port
- Copy html/ directory into runtime image for /html/ endpoint
- Set WORKDIR to / so relative paths resolve correctly

Also bumps Go version from 1.20 to 1.21 in go.mod.

https://claude.ai/code/session_01GkWCj6JKLSqEtnkBpPoFBL
The Go build produces an extensionless binary on Linux which wasn't
covered by the existing *.exe/*.dll/*.so patterns.

https://claude.ai/code/session_01GkWCj6JKLSqEtnkBpPoFBL
@pareshpawar pareshpawar merged commit cea7627 into main Apr 15, 2026
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