Skip to content

[S3] fclose(): supplied resource is not a valid stream resource #28496

Closed

Description

@pierreozoux

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Looks similar to #23373

Steps to reproduce

  1. Go to web UI
  2. upload a somehow big file, bigger than the chunk size that is by default 10MB, so for instance 100MB

Expected behaviour

There shouldn't be errors in the nextcloud.log

Actual behaviour

There are errors.

Server configuration

Nextcloud version: 20.0.11

Where did you install Nextcloud from: docker

Are you using external storage, if yes which one: ceph rados gateway / s3 compatible

Are you using encryption: no

Logs

Nextcloud log (data/nextcloud.log)

Nextcloud log
{
   "reqId":"RgbGEzK8IUMkYzSQjFY3",
   "level":3,
   "time":"2021-08-18T07:42:32+00:00",
   "remoteAddr":"49.12.19.171",
   "user":"admin",
   "app":"PHP",
   "method":"PUT",
   "url":"/remote.php/dav/uploads/admin/web-file-upload-761e5de13b91cf0c4ab6f34b6164e593-1629271135519/754974720",
   "message":{
      "Exception":"Error",
      "Message":"fclose(): supplied resource is not a valid stream resource at /usr/src/nextcloud/3rdparty/icewind/streams/src/Wrapper.php#132",
      "Code":0,
      "Trace":[
         {
            "function":"onError",
            "class":"OC\\Log\\ErrorHandler",
            "type":"::",
            "args":[
               2,
               "fclose(): supplied resource is not a valid stream resource",
               "/usr/src/nextcloud/3rdparty/icewind/streams/src/Wrapper.php",
               132,
               [
                  
               ]
            ]
         },
         {
            "file":"/usr/src/nextcloud/3rdparty/icewind/streams/src/Wrapper.php",
            "line":132,
            "function":"fclose",
            "args":[
               null
            ]
         },
         {
            "file":"/usr/src/nextcloud/3rdparty/icewind/streams/src/CallbackWrapper.php",
            "line":119,
            "function":"stream_close",
            "class":"Icewind\\Streams\\Wrapper",
            "type":"->",
            "args":[
               
            ]
         },
         {
            "function":"stream_close",
            "class":"Icewind\\Streams\\CallbackWrapper",
            "type":"->",
            "args":[
               
            ]
         },
         {
            "file":"/usr/src/nextcloud/3rdparty/guzzlehttp/psr7/src/Stream.php",
            "line":105,
            "function":"fclose",
            "args":[
               null
            ]
         },
         {
            "file":"/usr/src/nextcloud/3rdparty/guzzlehttp/psr7/src/Stream.php",
            "line":73,
            "function":"close",
            "class":"GuzzleHttp\\Psr7\\Stream",
            "type":"->",
            "args":[
               
            ]
         },
         {
            "function":"__destruct",
            "class":"GuzzleHttp\\Psr7\\Stream",
            "type":"->",
            "args":[
               
            ]
         }
      ],
      "File":"/usr/src/nextcloud/lib/private/Log/ErrorHandler.php",
      "Line":91,
      "CustomMessage":"--"
   },
   "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:92.0) Gecko/20100101 Firefox/92.0",
   "version":"20.0.11.1"
}

Activity

  1. juliusknorr commented on Aug 18, 2021

    @juliusknorr
    Member

    Should have been fixed by icewind1991/Streams@93bce47 but seems the package didn't get an update on the stable branches in the 3rdparty repo.

  2. added
    1. to developAccepted and waiting to be taken care of
    and removed
    0. Needs triagePending check for reproducibility or if it fits our roadmap
    on Aug 18, 2021
  3. juliusknorr commented on Aug 18, 2021

    @juliusknorr
    Member

    @skjnldsv @ChristophWurst Should we maybe also setup dependabot for minor updates in the stable branches of https://github.com/nextcloud/3rdparty ?

  4. ChristophWurst commented on Aug 18, 2021

    @ChristophWurst
    Member

    Sure :)

  5. PVince81 commented on Oct 8, 2021

    @PVince81
    Member

    also just reproduced on 21.0.5 with minio object store docker:

    1. run docker run -p 9000:9000 minio/minio server /data
    2. setup NC
    3. edit config.php and set the settings like below
    'objectstore' =>
    	array (
    		'class' => 'OC\\Files\\ObjectStore\\S3',
    		'arguments' =>
    		array (
    			'bucket' => 'nextcloud-dev',
    			'key' => 'minioadmin',
    			'secret' => 'minioadmin',
    			'hostname' => 'localhost',
    			'port' => '9000',
    			'use_ssl' => false,
    			'use_path_style' => true,
    		),
    	),
    
    1. login as admin/admin

    I see this in the log:

    {"reqId":"my0o14wBcN7ZTAbx1Obt","level":3,"time":"2021-10-08T07:27:49+00:00","remoteAddr":"127.0.0.1","user":"admin","app":"PHP","method":"GET","url":"/index.php/apps/files/","message":{"Exception":"Error","Message":"fclose(): supplied resource is not a valid stream resource at /srv/www/htdocs/server/3rdparty/icewind/streams/src/Wrapper.php#96","Code":0,"Trace":[{"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::","args":[2,"fclose(): supplied resource is not a valid stream resource","/srv/www/htdocs/server/3rdparty/icewind/streams/src/Wrapper.php",96,[]]},{"file":"/srv/www/htdocs/server/3rdparty/icewind/streams/src/Wrapper.php","line":96,"function":"fclose","args":[null]},{"file":"/srv/www/htdocs/server/3rdparty/icewind/streams/src/CallbackWrapper.php","line":117,"function":"stream_close","class":"Icewind\\Streams\\Wrapper","type":"->","args":[]},{"function":"stream_close","class":"Icewind\\Streams\\CallbackWrapper","type":"->","args":[]},{"file":"/srv/www/htdocs/server/3rdparty/guzzlehttp/psr7/src/Stream.php","line":108,"function":"fclose","args":[null]},{"file":"/srv/www/htdocs/server/3rdparty/guzzlehttp/psr7/src/Stream.php","line":74,"function":"close","class":"GuzzleHttp\\Psr7\\Stream","type":"->","args":[]},{"function":"__destruct","class":"GuzzleHttp\\Psr7\\Stream","type":"->","args":[]}],"File":"/srv/www/htdocs/server/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36","version":"21.0.5.1"}
    
  6. PVince81 commented on Oct 8, 2021

    @PVince81
    Member
  7. self-assigned this
    on Oct 8, 2021
  8. PVince81 commented on Oct 18, 2021

    @PVince81
    Member

    Reponing to track backport to stable20 because I need somewhere to put the long checklist:

  9. kesselb commented on Oct 22, 2021

    @kesselb
    Contributor

    PHP Warning: Declaration of OC\Files\Stream\Encryption::loadContext($name) should be compatible with Icewind\Streams\Wrapper::loadContext($name = NULL) in /drone/src/lib/private/Files/Stream/Encryption.php on line 0

    PHP Warning: Declaration of OC\Files\Stream\Encryption::wrapSource($source, $context, $protocol, $class, $mode = 'r+') should be compatible with Icewind\Streams\WrapperHandler::wrapSource($source, $context = Array, $protocol = NULL, $class = NULL, $mode = 'r+') in /drone/src/lib/private/Files/Stream/Encryption.php on line 0

    Found the above error messages in a backport for stable20: https://drone.nextcloud.com/nextcloud/server/11030/14/5

    The update from 0.7.1 to 0.7.2 for stable21 required some code changes: #24533

    Unfortunately the 0.7.2 update and the code changes were not backported to stable20.

  10. PVince81 commented on Oct 25, 2021

    @PVince81
    Member

    backports are merged, closing

  11. PVince81 commented on Oct 25, 2021

    @PVince81
    Member

    PHP Warning: Declaration of OC\Files\Stream\Encryption::loadContext($name) should be compatible with Icewind\Streams\Wrapper::loadContext($name = NULL) in /drone/src/lib/private/Files/Stream/Encryption.php on line 0

    PHP Warning: Declaration of OC\Files\Stream\Encryption::wrapSource($source, $context, $protocol, $class, $mode = 'r+') should be compatible with Icewind\Streams\WrapperHandler::wrapSource($source, $context = Array, $protocol = NULL, $class = NULL, $mode = 'r+') in /drone/src/lib/private/Files/Stream/Encryption.php on line 0

    Found the above error messages in a backport for stable20: https://drone.nextcloud.com/nextcloud/server/11030/14/5

    The update from 0.7.1 to 0.7.2 for stable21 required some code changes: #24533

    Unfortunately the 0.7.2 update and the code changes were not backported to stable20.

    oops, I'll recheck

  12. PVince81 commented on Oct 25, 2021

    @PVince81
    Member

    PR here for the missing code changes for stable20: #29426

  13. skjnldsv commented on Oct 25, 2021

    @skjnldsv
    Member

    PR here for the missing code changes for stable20: #29426

    Merged

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions