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

TypeError : fclose(): supplied resource is not a valid stream resource #67

Closed
cgimenes opened this issue Jan 22, 2024 · 9 comments
Closed

Comments

@cgimenes
Copy link

I don't think @fclose($descriptor); at src/MockWebServer.php#L135 is working.
Maybe wrap in an empty try/catch?

@cgimenes
Copy link
Author

What do you think of? #68

@donatj
Copy link
Owner

donatj commented Jan 22, 2024

Can you provide a code example of how to trigger the issue?

@cgimenes
Copy link
Author

Just to be clear. I was using 2.6.1 and after upgrading to 2.7.1 I started getting TypeError : fclose(): supplied resource is not a valid stream resource when calling MockWebServer->stop()

@donatj
Copy link
Owner

donatj commented Jan 22, 2024

I can't come up with any way that that a descriptor should be in that array and an open valid stream resource.

Are you using any sort of test parallelizers or such?

@cgimenes
Copy link
Author

Yes, I'm using. But, I think I may found out why I'm the only one having this issue. I'm calling stop() twice.

@cgimenes
Copy link
Author

cgimenes commented Jan 22, 2024

<?php

declare(strict_types=1);

use donatj\MockWebServer\MockWebServer;
use PHPUnit\Framework\TestCase;

class ExampleTest extends TestCase
{
    public function setUp(): void
    {
        $this->server = new MockWebServer();
        $this->server->start();
    }

    public function tearDown(): void
    {
        $this->server->stop();
        $this->server->stop();
    }

    public function testValid(): void
    {
        self::assertTrue(true);
    }
}

@donatj
Copy link
Owner

donatj commented Jan 22, 2024

You know, that's the one thing I didn't think of. That would do it. I will fix that!

@donatj
Copy link
Owner

donatj commented Jan 22, 2024

Published a release with a fix and a regression test ;)

Thanks for the report!

https://github.com/donatj/mock-webserver/releases/tag/v2.7.2

@donatj donatj closed this as completed Jan 22, 2024
@cgimenes
Copy link
Author

Thank you!

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

No branches or pull requests

2 participants