unjs / httpxy

πŸ”€ A Full-Featured HTTP and WebSocket Proxy for Node.js
Other
194 stars 12 forks source link

fix: handle client `close` event #8

Closed didavid61202 closed 1 year ago

didavid61202 commented 1 year ago

πŸ”— Linked issue

Downstream discussion: https://github.com/nuxt/nuxt/discussions/16046

❓ Type of change

πŸ“š Description

Proxy respond did not get 'abort/destroy' when the client close the request, causing situation in Server sent event where user trigger close from the clinet EventSource, but the server request did not trigger the close listen as expected.

Reproduction: https://stackblitz.com/edit/unjs-nitro-khtcjd?file=routes%2Fsse.ts Server Sent Event(SSE) example code: https://gist.github.com/Atinux/05836469acca9649fa2b9e865df898a2

Downstream discussion: https://github.com/nuxt/nuxt/discussions/16046 Related issues: https://github.com/http-party/node-http-proxy/issues/1520

πŸ“ Checklist

codecov[bot] commented 1 year ago

Codecov Report

Merging #8 (226388b) into main (f8cde14) will increase coverage by 0.09%. The diff coverage is 100.00%.

:exclamation: Current head 226388b differs from pull request most recent head e900b91. Consider uploading reports for the commit e900b91 to get more accurate results

@@            Coverage Diff             @@
##             main       #8      +/-   ##
==========================================
+ Coverage   64.98%   65.08%   +0.09%     
==========================================
  Files           8        8              
  Lines        1048     1051       +3     
  Branches       73       74       +1     
==========================================
+ Hits          681      684       +3     
  Misses        366      366              
  Partials        1        1              
Files Changed Coverage Ξ”
src/middleware/web-incoming.ts 70.55% <100.00%> (+0.49%) :arrow_up:
pi0 commented 1 year ago

Thanks for this PR. LGTM. It is worth to also check other upstream PRs for abort handling https://github.com/http-party/node-http-proxy/pull/1580 https://github.com/http-party/node-http-proxy/pull/1559