Skip to content

Restore trim-safe server routing and response dispatch - #1397

Closed
quinnj wants to merge 6 commits into
masterfrom
codex/restore-native-server-trim
Closed

quinnj wants to merge 6 commits into
masterfrom
codex/restore-native-server-trim

Conversation

@quinnj

@quinnj quinnj commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Native applications that use HTTP.Router fail JuliaC's --trim=safe verifier on HTTP 2.9. Route registration and the route trie erase handler types, routed handlers return responses whose body type is unknown, and HTTP/2 shutdown calls an erased Function. LeagueEasy's production build reported 48 verifier errors; the new standalone router workload reproduced 15 before this change.

Changes

  • Router registration specializes on the handler type, and route segments are stored with concrete types.
  • HTTP/2 shutdown state is stored in a concrete struct instead of a closure (all builds).
  • The server narrows handler responses to known buffered body types before writing them. Default builds fall back to normal dispatch for any other body type, so they accept every body type as before.
  • New opt-in trim_strict_bodies preference. With it enabled:
    • routers call each handler through a per-handler-type C entry point;
    • the narrowed body types (now including servecontent byte ranges over a byte vector) are the only ones accepted; the server answers other body types with a 500;
    • the precompile workload is skipped.
  • The server guide documents the preference.

Tests

  • A new native router workload (captured closures, middleware, regex and wildcard routes, a byte-range servecontent response, 404/405, shutdown) must compile with zero verifier errors.
  • The handler test file also runs in a child process with the preference enabled.
  • New tests cover custom request and response bodies in both modes, handler retention across GC, and exceptions thrown from routed handlers.

Validation

  • Julia 1.13.1, macOS arm64: the router workload has zero verifier errors and the native executable serves every route, including the 206 range response. Removing the range-body branch makes that request return 500, so the workload covers it.
  • The handler tests pass in both modes, and the HTTP/1 and HTTP/2 server tests pass in default mode.
  • Full HTTP suite and docs build pass in CI.
  • LeagueEasy builds, links, and passes its full backend suite and a native Linux API smoke test with this branch. It has not been deployed.

Co-authored by Codex

AI disclosure: This work was prepared with assistance from OpenAI Codex and Claude Code.

🤖 Generated with Claude Code

@quinnj
quinnj marked this pull request as ready for review October 8, 2026 18:52
@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.24324% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.83%. Comparing base (52ba567) to head (5db12f1).

Files with missing lines Patch % Lines
src/http_handlers.jl 90.69% 4 Missing ⚠️
src/http_core.jl 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1397      +/-   ##
==========================================
+ Coverage   90.80%   90.83%   +0.02%     
==========================================
  Files          31       31              
  Lines       12835    12881      +46     
==========================================
+ Hits        11655    11700      +45     
- Misses       1180     1181       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

quinnj and others added 4 commits October 8, 2026 13:02
`servecontent` over a byte vector answers a Range request with a
`BytesBody` over a contiguous view. Strict mode rejected that body type,
so a natively built server answered byte-range requests (video seeking)
with a 500. Add it to the strict body set and cover it in the native
router workload.

Default builds now skip the narrowing entirely and dispatch exactly as
before. Build the handler C entrypoint with a plain `@cfunction` over the
callable's type instead of a generated function and wrapper struct, and
shorten the native-build guide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep one narrowing path for both modes so the whole suite exercises the
strict body set; strict mode only adds the final throw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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