Comments (9)
My first instinct is that I don't believe this is an error ... I've encountered this before with xdebug enabled. Try adjusting the following setting or temporarily disabling xdebug:
xdebug.max_nesting_level = 200
That said, it might be an error :) Let me know if this makes it go away and if not I'll look into it further.
from http-client.
Update: I'm getting errors now. Strange. Working on it.
from http-client.
I still get it with 200 levels.
In my local copy I have worked around this by moving $callback($watcherId);
after reschedule/unset block in doAlarmCallback()
But for all I know there could be a good reason it's done first and I might be breaking something else.
from http-client.
Oh, wait. I realize what the problem is. Your reproduction script is specifying an event reactor that's different from the one used by the AsyncClient
underlying the blocking Client
.
I have a disclaimer in the docblock but it's probably not enough:
The constructor parameters allow for lazy injection and improved testability. Unless you really know what you're doing you shouldn't specify your own arguments when instantiating Artax\Client objects.
The issue here is that the event reactor must be the same one passed to the AsyncClient
. If you change your code to this it will work no problem:
<?php
$reactor = (new \Alert\ReactorFactory)->select();
$asyncClient = new \Artax\AsyncClient($reactor);
$client = new \Artax\Client($reactor, $asyncClient);
The reasoning for this is ...
The blocking Artax\Client
class simply wraps the Artax\AsyncClient
. For the async client to function it needs an event reactor. But people who want to use the basic client don't want or need to know about what's going on under the hood. The constructor allows you to pass in the dependencies to make testing possible but it doesn't require you to do so.
I could add methods to AsyncClient
to start and stop the reactor as needed for the blocking client (to adhere to the Law of Demeter and not reach through it to access the reactor). However I didn't want to complicate the async client's interface with more public methods. Instead I choose to inject the reactor and async clients separately.
The only downside is that until I can find a better way to do this you're forced to inject both. There's probably a better way to handle this but for now just make sure you manually create the async client object with the same event reactor and pass that in as well. In the meantime I can probably add some more error handling and documentationto help others avoid this same pitfall.
from http-client.
Doh. That was part of the problem. But it looks like there's still a memory leak. Back to work.
from http-client.
I started by copy/pasting from your examples ;)
Are you sure that's the issue? Checking the constructor, it looks like my supplied reactor is used for the AsyncClient
function __construct(Reactor $reactor = NULL, AsyncClient $asyncClient = NULL) {
$this->reactor = $reactor ?: (new ReactorFactory)->select();
$this->asyncClient = $asyncClient ?: new AsyncClient($this->reactor);
from http-client.
Yeah you're right. My brain is clearly addled this morning. In any case, moving the callback down the method as you suggested solves the problem and all the test cases still pass at 92% coverage so I don't foresee any problems. I'll tag an alert v.0.1.1 shortly with that fix. As always, thanks for the feedback and bug-finding.
from http-client.
Ah crap, should have raised the issue on Alert not Artax, I blame submodules!
from http-client.
This issue has been addressed in the Alert dependency (which has been updated). A new version of Artax has been tagged at v0.6.1 incorporating the latest Alert updates.
from http-client.
Related Issues (20)
- 5.x: Undefined array key 1689, Http2ConnectionProcessor.php:1316 HOT 5
- 5.x: Review Form API
- Memory issue in HTTP 2 connection HOT 1
- 5.x: Call to a member function getFuture() on null HOT 3
- If a response redirects, it sends back raw gzip instead of decoded content HOT 1
- `Form` not sent with same semantics as `FormBody` HOT 4
- Remove UnprocessedRequestException HOT 1
- Beta 11 encodes repeated form fields differently HOT 2
- Double redirect still returns gzip compressed data
- 4.x's php version depends changed because of league/uri HOT 2
- Log errors in LogHttpArchive
- [v5.0.0-beta.14] Invalid request phase transition from Connect to RequestHeaders HOT 4
- Amp\Http\Client\TimeoutException: Allowed transfer timeout exceeded, took longer than 10 s in /home/madeline/vendor/amphp/http-client/src/Connection/Internal/Http2ConnectionProcessor.php:1562 HOT 1
- Allow detection whether a connection has been reused
- [v5.0.0 Beta 15] Invalid request phase transition from Rejected to Failed HOT 1
- requestEnd() is not called in event listener in sync mode. HOT 5
- Response streaming during request upload
- Invalid certificate throws a misleading error
- [5.1.0] Deadlock and warnings when Http2 connection breaks HOT 1
- Unexpected behavior: Closing body stream result in an error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http-client.