Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to a member function promise() on null #319

Open
xpader opened this issue Mar 20, 2023 · 6 comments
Open

Call to a member function promise() on null #319

xpader opened this issue Mar 20, 2023 · 6 comments
Labels

Comments

@xpader
Copy link
Contributor

xpader commented Mar 20, 2023

It's a weird problem

Call to a member function promise() on null in /home/web/apps/t-task-wind/releases/147/vendor/amphp/http-client/src/Connection/Internal/Http2ConnectionProcessor.php:1167

But I see there is check on the code https://github.com/amphp/http-client/blob/4.x/src/Connection/Internal/Http2ConnectionProcessor.php#L1165

@kelunik
Copy link
Member

kelunik commented Apr 13, 2023

This this an issue you can reproduce?

@kelunik kelunik added the bug label Apr 13, 2023
@kelunik kelunik closed this as not planned Won't fix, can't repro, duplicate, stale May 4, 2023
@xpader
Copy link
Contributor Author

xpader commented May 5, 2023

I don't know how to reproduce this, it happends everyday on my server, not many.
Look like it happend sometime on file upload request with FileBody.

@xpader
Copy link
Contributor Author

xpader commented Apr 24, 2024

Still happends.

Previous Error: Call to a member function promise() on null in /home/web/apps/t-task-wind/releases/298/vendor/amphp/http-client/src/Connection/Internal/Http2ConnectionProcessor.php:1169

@xpader
Copy link
Contributor Author

xpader commented Jul 2, 2024

I have make a little change to make sure not get a null pendingResponse.
Get a prepared pendingResponse and not use $http2stream->pendingResponse

Add code after (before write or read some in async) https://github.com/amphp/http-client/blob/4.x/src/Connection/Internal/Http2ConnectionProcessor.php#L1125

$pendingResponse = $http2stream->pendingResponse;

Change https://github.com/amphp/http-client/blob/4.x/src/Connection/Internal/Http2ConnectionProcessor.php#L1169 to

return yield $pendingResponse->promise();

Now the error has turned into a different kind of situation:

Amp\Http\Client\TimeoutException: Allowed transfer timeout exceeded, took longer than 30000 ms in /home/web/apps/t-task-wind/releases/342/vendor/amphp/http-client/src/Connection/Internal/Http2ConnectionProcessor.php:1104 [] []

@kelunik kelunik reopened this Jul 3, 2024
@xpader
Copy link
Contributor Author

xpader commented Jul 10, 2024

I was upload through http proxy with "amphp/http-tunnel": "^1.0", when set request protocol force to 1.1, and upload a large file, get below error after about 15 seconds:

Amp\ByteStream\StreamException: Failed to write to stream after multiple attempts; fwrite(): SSL: Broken pipe in ./vendor/amphp/byte-stream/lib/ResourceOutputStream.php:107

When remove force protocol setting, it will stuck at \Amp\Http\Client\Connection\Internal\Http2ConnectionProcessor::writeBufferedData, position:

        if ($windowSize > 0) {
            // Read next body chunk if less than 8192 bytes will remain in the buffer
            if ($length - 8192 < $windowSize && $stream->windowSizeIncrease) {
                $deferred = $stream->windowSizeIncrease;
                $stream->windowSizeIncrease = null;
                $deferred->resolve();
            }

            $data = $stream->requestBodyBuffer;
            $end = $windowSize - $this->frameSizeLimit;

            $stream->clientWindow -= $windowSize;
            $this->clientWindow -= $windowSize;

            for ($off = 0; $off < $end; $off += $this->frameSizeLimit) {
                $this->writeFrame(
                    Http2Parser::DATA,
                    Http2Parser::NO_FLAG,
                    $stream->id,
                    \substr($data, $off, $this->frameSizeLimit)
                );
            }

            //stuck at writeFrame here:
            $promise = $this->writeFrame(
                Http2Parser::DATA,
                Http2Parser::NO_FLAG,
                $stream->id,
                \substr($data, $off, $windowSize - $off)
            );

            $stream->requestBodyBuffer = \substr($data, $windowSize);
            $stream->enableInactivityWatcher();

            return $promise;
        }

@xpader
Copy link
Contributor Author

xpader commented Jul 11, 2024

It's be a little strange, sometime it's just stuck there, sometimes it throw error ,Allowed transfer timeout exceeded, took longer than 30000 ms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants