ajaishankar / openapi-typescript-fetch

A typed fetch client for openapi-typescript
MIT License
233 stars 54 forks source link

Issue with post middleware when it clones the response #69

Open vargas88hugo opened 6 months ago

vargas88hugo commented 6 months ago

Hi all,

First of all, thank you for you excellent library.

I wanted to let you know I found an issue while using a custom post middleware in my autogenerated client. It seems that the autogenerated runtime.ts file is passing a cloned response, which can lead to timeout issues when dealing with large responses.

This is part of the code of the autogenerated runtime.ts file that I updated:

for (const middleware of this.middleware) {
  if (middleware.post) {
      response = await middleware.post({
          fetch: this.fetchApi,
          url: fetchParams.url,
          init: fetchParams.init,
          response: response, // response.clone() method was deleted because it doesn't support large responses
      }) || response;
  }
}

I'm wondering if this change may cause unexpected problems and if you have found any better approach for this.

Thank you for your attention to this matter. Looking forward to your insights.