guzzle-cache-middleware icon indicating copy to clipboard operation
guzzle-cache-middleware copied to clipboard

Argument #1 ($stream) must be of type resource, int given

Open Legion112 opened this issue 2 years ago • 16 comments

I am getting this warning. Probably problem is part of this PR

image

Packages:

gregurco/guzzle-bundle-cache-plugin | v3.0.0
guzzlehttp/guzzle | 7.5.0
guzzlehttp/promises | 1.5.2
guzzlehttp/psr7 | 2.4.3
http-interop/http-factory-guzzle | 1.2.0
kevinrob/guzzle-cache-middleware | v4.0.2

Legion112 avatar Jan 31 '23 06:01 Legion112

I am also having this issue, any fix? thank you

AhmadOf avatar Feb 27 '23 10:02 AhmadOf

If your package version greater or equal when mine. Try to clean cache this probably due to serialization error. Or wait a while.

Legion112 avatar Feb 28 '23 06:02 Legion112

Probably part of https://github.com/Kevinrob/guzzle-cache-middleware/issues/165

Legion112 avatar Feb 28 '23 06:02 Legion112

I am facing same error

Fatal error: Uncaught TypeError: fseek(): Argument #1 ($stream) must be of type resource, int given in /vendor/guzzlehttp/psr7/src/Stream.php:211

did you found any solution?

I am using [guzzle-cache-middleware:4.1.2].

rahulgupta-acquia avatar Sep 12 '23 13:09 rahulgupta-acquia

Is there any solution for this problem without clearing the existing cache?

whoisnobody avatar Feb 19 '24 09:02 whoisnobody

@whoisnobody wait for a while when cache will expire.

Legion112 avatar Feb 19 '24 11:02 Legion112

@whoisnobody wait for a while when cache will expire.

I have a very long TTL for the cache and I cannot just clear it. I need to have some middle solution for reading an old cache with the new package. At the moment I hold with v3.5, but I don't want to stuck with this version forever.

whoisnobody avatar Feb 19 '24 11:02 whoisnobody

@whoisnobody check out this issue

https://github.com/Kevinrob/guzzle-cache-middleware/issues/165

They offer some solutions

Legion112 avatar Feb 19 '24 12:02 Legion112

Clearing the cache is not the solution for me.

whoisnobody avatar Feb 19 '24 13:02 whoisnobody

@whoisnobody

At the moment, I have a custom PSR16 cache implementation to avoid the issue. I think having something handling serialization of CacheEntry as raw_string or at least, normalized data (stdClass, array or scalar values) which is immune to this issue

Legion112 avatar Feb 20 '24 05:02 Legion112

@Legion112 I consider this as a proposition of solution not a ready for use solution. I know that I can implement PSR16 cache class, and also I can implement my own middleware for guzzle and don't use this package. Is that your point?

This package with this changes implemented in v4 is not intended to be safely used when upgraded. It needs extra actions (clearing cache or wait for it to expire). I didn't see any notice about that potential problem from maintainer. It's especially more dangerous, because more often it may affect production than test or dev environments.

whoisnobody avatar Feb 20 '24 07:02 whoisnobody

I agree with you @whoisnobody

Probably this is critical issue @Kevinrob

Legion112 avatar Feb 20 '24 18:02 Legion112

I'd also agree that this is a critical issue. It caused a full site outage in our production environment and led to us missing an uptime SLO.

dbhynds avatar Feb 20 '24 22:02 dbhynds

Does anyone want to suggest a fix in the form of a PR to this problem? I don't have much time in the next few weeks to watch this.

Kevinrob avatar Feb 21 '24 18:02 Kevinrob

I would propose serialization via symfony serializer

But I am not sure how to handle existing issues with different versions of class Need some try catching logic

Legion112 avatar Mar 05 '24 05:03 Legion112

I am facing the same issue, is there any solution or workaround so far?

hamzaahmadse avatar Jun 01 '24 12:06 hamzaahmadse