Skip to content

fix: crash and RFC compliance edge cases - #121

Merged
daquinoaldo merged 11 commits into
masterfrom
fix/edge-case-bugs
Sep 15, 2026
Merged

daquinoaldo merged 11 commits into
masterfrom
fix/edge-case-bugs

Conversation

@daquinoaldo

@daquinoaldo daquinoaldo commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes all ten crash, hang, RFC-compliance, proxy, and response-quality bugs found in the review. Each fix is a separate commit; the edge-case test suite lands first.

  • Malformed percent-encoding crashed the server: /%zz threw URIError; now rejected safely. (904a911)
  • Directory without index.html crashed the server: now serves 404. (f6209f7)
  • If-Modified-Since alone never produced 304: now honored per RFC 9110. (f407c96)
  • Upstream dying mid-response hung clients: client socket now closes. (9db8e12)
  • Proxy CORS preflight hit the upstream: OPTIONS now returns 204 directly. (98305ef)
  • Packaged update check could raise an uncaught callback error: callback failures are contained. (b3f8b15)
  • Multi-range requests incorrectly returned 416: first range is served. (1f0ab67)
  • WebSocket upgrades were unsupported: HTTP and HTTPS upstream upgrade tunneling added. (28183b9)
  • Existing X-Forwarded-For was overwritten: client address is appended. (330e42d)
  • Static 400/403/405/416 responses had empty bodies: descriptive text bodies added. (e998c05)

Verification

  • Edge-case suite and full tests pass where ports are available.
  • pnpm lint passes.
  • The two redirect tests are blocked locally by an unrelated node server.js process occupying port 8080.

🤖 Generated with OpenCode (Smart-router)

Add an edge-case suite covering malformed percent-encoding, directories
without index.html, if-modified-since handling, proxy upstream failure
mid-response, and CORS preflight on the proxy path. Tests asserting the
desired behavior fail until the corresponding source fixes land.

Extend makeRequest to accept a custom HTTP method.

🤖 Generated with [OpenCode](https://opencode.ai) (Smart-router)
decodeURIComponent throws URIError on sequences like /%zz, which escaped
the request handler and killed the server. Catch the error and reject
the request.

🤖 Generated with [OpenCode](https://opencode.ai) (Smart-router)
A trailing-slash request to a directory without index.html rewrote the
target inside a try/catch and then stat'ed and read it outside, crashing
the server with an uncaught ENOENT. Validate the rewritten target before
serving.

🤖 Generated with [OpenCode](https://opencode.ai) (Smart-router)
RFC 9110 requires honoring If-Modified-Since on its own; the previous
condition only returned 304 when if-none-match was also present. Skip
unparseable dates instead of comparing them.

🤖 Generated with [OpenCode](https://opencode.ai) (Smart-router)
The proxy piped the upstream response without an error handler, so an
upstream that broke mid-body left the client hanging on an open
connection forever. Destroy the client socket when the upstream response
errors.

🤖 Generated with [OpenCode](https://opencode.ai) (Smart-router)
OPTIONS requests were forwarded to the upstream; answer them directly
with 204 so preflights succeed even when the upstream rejects or cannot
handle them.

Also fix the edge-case test harness: resolve the request path from an
env var (argv is unreliable under node --eval), import the module with a
cwd-relative path, run the child with --use-system-ca, and accept the
403 that malformed percent-encoding now returns.

🤖 Generated with [OpenCode](https://opencode.ai) (Smart-router)
@daquinoaldo daquinoaldo self-assigned this Sep 15, 2026
🤖 Generated with [OpenCode](https://opencode.ai) (Smart-router)
🤖 Generated with [OpenCode](https://opencode.ai) (Smart-router)
🤖 Generated with [OpenCode](https://opencode.ai) (Smart-router)
🤖 Generated with [OpenCode](https://opencode.ai) (Smart-router)
🤖 Generated with [OpenCode](https://opencode.ai) (Smart-router)
@daquinoaldo
daquinoaldo merged commit 8dea99e into master Sep 15, 2026
8 checks passed
@daquinoaldo
daquinoaldo deleted the fix/edge-case-bugs branch September 15, 2026 17:17
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