hey-api / openapi-ts

🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more. Support: @mrlubos
https://heyapi.dev
Other
1.29k stars 102 forks source link

Streaming HTTP query support #859

Open Karakatiza666 opened 3 months ago

Karakatiza666 commented 3 months ago

Description

I am using @hey-api/client-fetch client. I don't know if I'm missing something, but when I try to make a POST request that results in an HTTP stream (not SSE, just stream of data I'd like to read via requestResult.response.body : ReadableStream) the request's Promise doesn't resolve (apparently because it waits for stram to end - I can see via backend the connection is successfully established). When calling plain fetch this works as expected - request Promise resolves and I can read the body stream. Is there a solution/workaround currently for this?

mrlubos commented 3 months ago

@Karakatiza666 are you able to create a StackBlitz example so we can debug this?

Karakatiza666 commented 3 months ago

Unfortunately now I don't really have the time to work on reproduction, hopefully I'll post something within a week

jpenna commented 1 month ago

Same problem here.

I'm using the axios client. You can see they have an example of how to work with streaming data in their docs: https://github.com/axios/axios?tab=readme-ov-file#axiosconfig

My code is doing exactly what they are showing, but I get the following warning from the browser:

The provided value 'stream' is not a valid enum value of type XMLHttpRequestResponseType.

await summarize({ path: { id }, responseType: 'stream' }).then((response) => {
    response.data.on('data', (data) => {
      console.log('axios', data); // nothing is printed
    });
  });