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

cohttp-eio: confusing use of the ~sw argument #1006

Open
smondet opened this issue Nov 9, 2023 · 1 comment
Open

cohttp-eio: confusing use of the ~sw argument #1006

smondet opened this issue Nov 9, 2023 · 1 comment

Comments

@smondet
Copy link

smondet commented Nov 9, 2023

The Cohttp_eio.Client.call function takes a ~sw and returns a Body.t. calling Eio.Flow.read_all on the body after getting out of the Switch.run can cause a “use-after-close” exception from Eio:

Invalid-argument: readv: file descriptor used after calling close!

It gives the impression of defeating the purpose of eio-swtches, right?

PS: the documentation does say "Consume [response_body] in a timely fashion." which is a bit vague :)

@talex5
Copy link
Contributor

talex5 commented Nov 11, 2023

The purpose of the switch is to make sure that the connection gets freed, even if an error occurs. Ideally the type system would also make sure you don't use things after they're closed, but OCaml can't do that yet.

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

No branches or pull requests

3 participants