You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR fixes three lifecycle issues in the SwooleCoroutine HTTP adapter introduced in #230: it removes the superfluous nested go() per request, adds a try/finally block to clear the per-request DI container from coroutine context after each request, and drops the unnecessary go() wrapper around server startup.
Request handling (onRequest): each request handler now runs directly instead of being dispatched into a new child coroutine, aligning it with the regular Swoole adapter's behaviour and making execution order predictable.
Context cleanup (onRequest): the new try/finally ensures the __utopia_http_request_container key is removed from coroutine context even when the callback throws, preventing request-scoped resource leaks across coroutine reuse.
Startup (start): the onStartCallback and server->start() are now called directly in the active coroutine rather than being wrapped in a new go(), which matches the stated intent that this adapter should run inside an existing coroutine runtime.
Minor: getContainer() omits the Coroutine::getCid() !== -1 guard that the sibling Swoole/Server.php uses, which can produce a PHP warning if called outside a coroutine context.
Confidence Score: 5/5
Safe to merge; all three stated lifecycle fixes are correctly implemented with no blocking defects.
The only remaining finding is a missing defensive getCid() guard in getContainer() — a P2 style suggestion that does not affect normal operation since the adapter is coroutine-only by design.
No files require special attention; the single changed file src/Http/Adapter/SwooleCoroutine/Server.php looks correct overall.
Important Files Changed
Filename
Overview
src/Http/Adapter/SwooleCoroutine/Server.php
Fixes request lifecycle: removes nested go() wrapping, adds try/finally cleanup for coroutine context, and simplifies startup; getContainer() is missing a defensive Coroutine::getCid() guard present in the sibling adapter
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
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.
Summary
Why
Appwrite's switch to the coroutine HTTP adapter exposed a few lifecycle issues in the upstream adapter:
go(...), which made request execution less predictable and diverged from the regular Swoole adapter.go(...), even though this adapter is intended to run inside an existing coroutine runtime.These changes keep the adapter coroutine-only, but make its request lifecycle explicit and consistent.
Validation
composer format src/Http/Adapter/SwooleCoroutine/Server.phpcomposer lint src/Http/Adapter/SwooleCoroutine/Server.phpphp -l src/Http/Adapter/SwooleCoroutine/Server.phpvendor/bin/phpstan analyse -c phpstan.neon src/Http/Adapter/SwooleCoroutine/Server.php --memory-limit=512M