Skip to content

A suspended write() fails its own 'static' return-type check under bidirectional HTTP/2 load #226

Closed

Description

@EdmondDantes

Symptom

Under bidirectional HTTP/2 load — a large request body and a streamed response
on the same stream — the server prints

Fatal error: TrueAsync\HttpResponse::write(): Return value must be of type static, TrueAsync\HttpResponse returned in Unknown on line 0

and a large share of requests error out.

Reproduction

Server:

$server->addHttpHandler(function ($req, $res) {
    $body = $req->getBody();
    $res->setStatusCode(200)->setHeader('X-Echo-Len', (string)strlen($body));
    for ($i = 0; $i < 16; $i++) { $res->write(str_repeat('z', 65536)); }
    $res->end();
});

post.bin is 1 MiB; the response is 1 MiB.

h2load -n 400 -c 20 -m 8 -d post.bin http://127.0.0.1:PORT/
build errored fatal
52dbeb6 (main) 217 of 400 yes
6a0a64b (branch of #219) 157 of 400 yes

Both directions have to be large. -c 20 -m 8 with no request body finishes
400 of 400, and forcing write() backpressure alone with
setStreamWriteBufferBytes(4096) does not reproduce it.

What the message means

write() is declared public function write(string $chunk): static
(stubs/HttpResponse.php:228), which compiles to IS_STATIC in
stubs/HttpResponse.php_arginfo.h:63. PHP resolves static for an internal
method through the called scope of the current execute_data. The returned value
is a TrueAsync\HttpResponse, so the failure is the resolution, not the value:
the frame the check reads is not the one that called write().

write() suspends — HTTP/2 parks it when the per-stream chunk ring is full —
and getBody() suspends ahead of it on a large request body. "in Unknown on
line 0" says the error is raised with no PHP frame in scope, which is consistent
with the verification running after a resume that did not restore the call
frame.

writeMessage() carries the same IS_STATIC return type, and every other
suspending method that returns static is in the same position.

Found while reviewing #219 (PR 220); present on main and unrelated to that
change.

Activity

  1. added this to the Next3 milestone on Aug 22, 2026
  2. added a commit that references this issue on Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions