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

Unable to determine stream size. Did you forget to close or flush the stream? #34

Open
pandian1989 opened this issue Jan 31, 2025 · 9 comments
Labels

Comments

@pandian1989
Copy link

I am getting Unable to determine stream size. Did you forget to close or flush the stream? when i am use S3 as storage with streamwrapper. Can you suggest me how to resolve this issue.

@scheb
Copy link
Owner

scheb commented Jan 31, 2025

Writing data to S3 seems to have specific requirements. The logging implementation is very similar to what Monolog is doing and I believe Monolog doesn't support S3 out-of-the-box.

I've found this article on StackOverflow, describing that you need to do some client initialization first. Maybe that helps.

@pandian1989
Copy link
Author

pandian1989 commented Jan 31, 2025

Yeah. Same way i did client initialization like this

private function configureS3LogStorage(): void
    {
        $client = new S3Client([
            'region' => 'us-west-2',
            "version" => '2006-03-01',
            "credentials"=> [
                "key" => 'some key',
                "secret" => 'some secret'
            ]
        ]);
        $client->registerStreamWrapper();
    }

Before build graveyard, i call this function to initialize client with stream wrapper of s3 storage.

@scheb
Copy link
Owner

scheb commented Jan 31, 2025

Did you write your own log handler or are you using the standard one that comes with the library? If you're using the battery standard one I'd suggest you try it with a custom one specifically for the S3 use case.

@pandian1989
Copy link
Author

I'm using AnalyzerLogHandler which uses the inbuild StreamHandler . So I just register client and before build graveyard and it was working but concern is that whenever use concurrency of calls it throws.

Unable to determine stream size. Did you forget to close or flush the stream?

@scheb
Copy link
Owner

scheb commented Jan 31, 2025

I did understand this, but I also don't have an idea where this is coming from. My guess is that something in the way the standard StreamHandler workes is incompatible with the S3 protocol. Therefore my suggestion, to implement a custom handler specifically for S3.

@pandian1989
Copy link
Author

Can i have any sample contract to write custom handler and it would be helpful for me.

@scheb
Copy link
Owner

scheb commented Jan 31, 2025

Have a look at these classes: https://github.com/scheb/tombstone/tree/1.x/src/logger/Handler

@pandian1989
Copy link
Author

Is it possible to add fflush to flush file output buffer in stream handler because since flush method declared but not implemented in stream handler.

@scheb
Copy link
Owner

scheb commented Feb 5, 2025

Sorry, I don't understand what you mean.

I wouldn't want to touch the StreamHandler so much as this would potentially break other people's implementations. My recommendation is to implement a custom handler that fits your needs.

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

No branches or pull requests

2 participants