Repository navigation
[Server] Add Revolt and ReactPHP examples and fix session locks under an event loop - #636
Merged
Merged
Conversation
chr-hertel
requested review from
CodeWithKyrian,
Nyholm and
soyuka
as code owners
October 27, 2026 22:03
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Scheduler failures during transport-driven fiber resumes can escape protocol error handling, terminating stdio processing or HTTP streams without a final JSON-RPC error response.
3 open issues
What changed in this PR
Adds a Revolt-powered HTTP server example, building on #616’s fiber-scheduler support so request handlers can await asynchronous I/O without the SDK resuming their fibers prematurely.
Changes:
- Adds scheduler integration across handler fibers, protocols, client communication, and transports.
- Adds an AMPHP/Revolt example with timer-based tools and Inspector snapshot tests.
- Documents scheduler configuration and adds unit coverage for event-loop interactions.
| File | Description |
|---|---|
tests/Unit/Server/Fiber/HandlerFibersTest.php |
Tests fiber ownership, suspension, and exception handling. |
tests/Unit/Server/Fiber/FakeEventLoop.php |
Provides a dependency-free test scheduler. |
tests/Unit/Server/Fiber/EventLoopToolCallTest.php |
Tests asynchronous tool calls across protocol eras. |
tests/Interop/Server/Http/snapshots/HttpRevoltTest-tools_list.json |
Records example tool schemas. |
tests/Interop/Server/Http/snapshots/HttpRevoltTest-tools_call-wait.json |
Records the wait tool result. |
tests/Interop/Server/Http/snapshots/HttpRevoltTest-tools_call-check_services.json |
Records concurrent service-check results. |
tests/Interop/Server/Http/snapshots/HttpRevoltTest-resources_templates_list.json |
Records empty resource templates. |
tests/Interop/Server/Http/snapshots/HttpRevoltTest-resources_list.json |
Records empty resources. |
tests/Interop/Server/Http/snapshots/HttpRevoltTest-prompts_list.json |
Records empty prompts. |
tests/Interop/Server/Http/HttpRevoltTest.php |
Runs Inspector checks against the Revolt example. |
tests/Interop/Server/Http/HttpInspectorSnapshotTestCase.php |
Allows custom server startup commands. |
src/Server/Transport/StreamableHttpTransport.php |
Uses scheduler-aware fiber resumption for HTTP. |
src/Server/Transport/StdioTransport.php |
Uses scheduler-aware fiber resumption for stdio. |
src/Server/Transport/BaseTransport.php |
Routes failed-yield resumption through handler management. |
src/Server/Stateless/StatelessProtocol.php |
Integrates scheduling into stateless handlers. |
src/Server/Protocol.php |
Integrates scheduling into handshake-era handlers. |
src/Server/Fiber/HandlerFiberState.php |
Tracks suspension, settlement, and handler errors. |
src/Server/Fiber/HandlerFibers.php |
Coordinates server-driven and runtime-driven fibers. |
src/Server/Fiber/FiberSettlement.php |
Provides settlement callbacks for schedulers. |
src/Server/Fiber/FiberSchedulerInterface.php |
Defines the runtime waiting contract. |
src/Server/ClientGateway.php |
Marks client-facing suspensions for the server. |
src/Server/Builder.php |
Exposes scheduler configuration to both protocols. |
examples/server/revolt/SlowTools.php |
Demonstrates asynchronous waits and concurrent checks. |
examples/server/revolt/server.php |
Hosts the example using AMPHP HTTP. |
examples/server/revolt/RevoltFiberScheduler.php |
Adapts settlement waiting to Revolt. |
examples/server/README.md |
Adds example startup instructions. |
docs/run/server-builder.md |
Documents scheduler configuration and limitations. |
composer.json |
Adds development dependencies and example autoloading. |
CHANGELOG.md |
Records scheduler support and fiber-handling changes. |
Review effort: Balanced
chr-hertel
force-pushed
the
revolt-example
branch
from
November 8, 2026 11:47
3cba941 to
82491c4
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The abandonment check misses exceptions caught in dispatchResult(), allowing a resumed ResponseEvent listener to trigger a late ErrorEvent after the request has already been answered.
1 open issue
3 resolved since last review
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Follow-up to #616 - adds
examples/server/revolt/andexamples/server/reactphp/, both with an Inspector test, covers the fiber schedulers on the real event loops and lands what was left open on #616.amphp/amp,amphp/http-server,revolt/event-loop,react/async,react/http&react/promiseStreamableHttpTransportstill blocks the loop while polling and streams viaecho- documented as a limit.