Skip to content

fix(http): schedule shared HTTP/WS servers on reactor - #8769

Closed
proggeramlug wants to merge 1 commit into
mainfrom
codex/issue-8747-http-reactor
Closed

fix(http): schedule shared HTTP/WS servers on reactor#8769
proggeramlug wants to merge 1 commit into
mainfrom
codex/issue-8747-http-reactor

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • schedule HTTP and HTTPS accept loops through Perry's explicit reactor-owned async bridge
  • use the same scheduling path for Unix round-robin file-descriptor injection
  • add an end-to-end regression for WebSocketServer attached to node:http followed by a plain fetch

The old blocking-FFI callback relied on an ambient Tokio context. Adding the ws native wrapper changed the link shape and could leave TcpListener::from_std without a reactor, aborting the process. Scheduling the listener future directly avoids that ambient-context dependency.

Fixes #8747

Testing

  • cargo check -p perry-ext-http --lib
  • cargo fmt -p perry-ext-http -p perry -- --check
  • python scripts/check_test_registration.py
  • cargo test -p perry --test issue_8747_http_ws_shared_server -- --nocapture
  • cargo test -p perry --test nested_object_literal_ws_inbound -- --nocapture

Summary by CodeRabbit

  • Bug Fixes

    • Improved HTTP and HTTPS connection handling for more reliable request serving and shutdown behavior.
    • Fixed shared HTTP and WebSocket server scenarios.
  • Tests

    • Added regression coverage confirming HTTP requests work correctly when a WebSocket server is attached.
    • Added safeguards to detect failed or stalled server processes.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5287f084-af43-4466-8cc7-5e3f06d637a9

📥 Commits

Reviewing files that changed from the base of the PR and between 1b0c300 and 7c17fc5.

📒 Files selected for processing (3)
  • crates/perry-ext-http/src/server/https_server.rs
  • crates/perry-ext-http/src/server/server.rs
  • crates/perry/tests/issue_8747_http_ws_shared_server.rs

Included review availability: Your plan provides up to 8 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

HTTPS and HTTP connection loops now use perry_ffi::spawn_async directly. A regression test covers a shared node:http and WebSocket server, including a successful plain HTTP request and timed process cleanup.

Changes

HTTP server async scheduling

Layer / File(s) Summary
Direct listener and worker scheduling
crates/perry-ext-http/src/server/https_server.rs, crates/perry-ext-http/src/server/server.rs
HTTPS, regular TCP, and SCHED_RR worker loops use direct perry_ffi::spawn_async scheduling. Existing socket setup, connection serving, error handling, and shutdown behavior remain in place.
Shared HTTP and WebSocket regression coverage
crates/perry/tests/issue_8747_http_ws_shared_server.rs
The integration test runs a shared HTTP and WebSocket server, verifies the http-ok response, and detects process failures or hangs.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to 7c17f

The PR routes shared HTTP/HTTPS and WebSocket server work through the reactor and adds regression coverage for the shared-server flow. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: scheduling shared HTTP and WebSocket servers on the reactor.
Description check ✅ Passed The description explains the cause and fix, identifies issue #8747, lists concrete changes, and provides relevant test commands.
Linked Issues check ✅ Passed The changes address issue #8747 by avoiding ambient Tokio context reliance and adding a regression test for shared HTTP and WebSocket servers.
Out of Scope Changes check ✅ Passed The server scheduling changes and regression test remain within the scope of issue #8747.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/issue-8747-http-reactor

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

proggeramlug added a commit that referenced this pull request Aug 24, 2026
…es, reactor HTTP scheduling (#8778)

Lands #8765, #8767, #8768 and #8769.

#8765 stops mysql2 prepared statements and pool transactions leaking
state across requests: each SQL string and parameter vector lives in one
owned request, a parameterless `query()` uses the text protocol, prepared
statements are request-scoped, and registry-backed mutable connection
references become serialized owned handles with safe close/release around
in-flight work.

#8767 admits arrays reached through one validated forwarding edge into
version-stable indexed loops, canonicalizing the compiler-private local
to the live array after the full header/fingerprint check. Per-iteration
fingerprint guards are retained, so callback-driven growth or a GC still
side-exits before the next effect, and invalid targets or longer chains
fail closed to the generic loop.

#8768 materializes ordinary parent prototypes.

#8769 schedules HTTP and HTTPS accept loops through the reactor-owned
async bridge, using the same path for Unix round-robin fd injection.

Changelog fragments added for #8765, #8767 and #8769; none carried one or
a skip-changelog label. No version bump.

Co-authored-by: Ralph Küpper <ralph@skelpo.com>
@proggeramlug

Copy link
Copy Markdown
Contributor Author

Landed on main via #8778 (squash 1f5c3bb80), with the rest of this batch.

Validated on the merged result: all 30 lint checkers, runtime 2674/0 at RUST_TEST_THREADS=1, codegen 1230/0, all codegen integration suites clean, and perry-ext-mysql2 --lib 10/0.

Added a changelog.d/ fragment — the PR had neither one nor a skip-changelog label.

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.

ext-http: SIGABRT 'there is no reactor running' (server/server.rs:913) — node:http server + ws WebSocketServer + fetch

1 participant