-
Notifications
You must be signed in to change notification settings - Fork 767
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
Providing http client to ReportDownloader causes duplicates in logs on consequent downloads #640
Comments
…t be changed by library
Hello, Thanks for reporting this, but If your use case needs to re-use the HTTP Client object, probably you need to clone it outside Best, |
I don't think I get it. I make new instance of reporter for each customer ID, why should it be illegal? And about HTTP Client: that means library should always accept clones since it changes the original handlers. If I try to use my http client after I've downloaded report, I'll have this new logger middleware running in my client, and I haven't asked for it. |
It's not illegal. I didn't say that. :) What I say is the
Can't you clone the HTTP client before passing it to the |
I could clone HTTP client before passing it, sure, but first of all it is not clear from documentation that my client will be modified. At second, if you look at my PR, provided client is only used to get its config and make new instance of library's client. The problem is that despite of config is being array, it points to an stack object, so when Google Library creates an new object it modifies original client's stack. So one should always clone client before passing it to library, why do so if we can (as in PR) just clone stack and return new client with new stack? About my case: I have Symfony project where I build my http client once and use it for different api's. I also have some custom handlers there for profiling sake, desired settings like timeouts e.t.c. So I use one instance of Guzzle Client through application, just getting it from DI container and passing to different sdk's. |
I'm kinda doing something like this Parallel Report Download, where multiple |
And I don't see why one should use 1 client for 1 request, I feel like 1 client should be used for all requests, because why not, why clone what does not need to be cloned. |
Alright, I was trying to find if there are other solutions that wouldn't need cloning, but it seems not quite feasible without changing the way that the ReportDownloader and other utils work. |
Thank you! |
I have one MCC account and multiple managed ad accounts. I use single session to get reports for all ad accounts. So in loop I have something like this:
Where
$this->client
is my ownGuzzleHttp\Client
. If I do so each call to report downloader produces$i + 1
log lines becausebefore
handlers keep stacking, so I get:The text was updated successfully, but these errors were encountered: