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

fix: should close both connections when client disconnects #270

Closed
wants to merge 2 commits into from

Conversation

mxschmitt
Copy link

@mxschmitt mxschmitt commented Jan 8, 2024

The order was the following:

CONNECT spocs.getpocket.com:443 HTTP/1.1  +26ms
proxy target spocs.getpocket.com:443 "connect" event +17ms
proxy ← ← ← HTTP request spocs.getpocket.com:443 socket "end" event +541ms
proxy ← ← ← HTTP request spocs.getpocket.com:443 socket "error" event:
proxy ← ← ← Error: write EPIPE
at afterWriteDispatched (node:internal/stream_base_commons:160:15)
at writeGeneric (node:internal/stream_base_commons:151:3)
at Socket._writeGeneric (node:net:952:11)
at Socket._write (node:net:964:8)
at writeOrBuffer (node:internal/streams/writable:447:12)
at _write (node:internal/streams/writable:389:10)
at Socket.Writable.write (node:internal/streams/writable:393:10)
at Socket.ondata (node:internal/streams/readable:817:22)
at Socket.emit (node:events:514:28)
at addChunk (node:internal/streams/readable:376:12)
at readableAddChunk (node:internal/streams/readable:349:9)
at Socket.Readable.push (node:internal/streams/readable:286:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23) +51ms
proxy ← ← ← HTTP request spocs.getpocket.com:443 socket "close" event +0ms
proxy ↓ ↓ ↓ proxy target spocs.getpocket.com:443 "end" event +57ms
proxy ↓ ↓ ↓ proxy target spocs.getpocket.com:443 "close" event +1ms

Before the change in the library it failed with:

  ● proxy › should close both connections when client disconnects

    expect(received).toEqual(expected) // deep equality

    Expected: "closed"
    Received: "writeOnly"

      225 |             ])
      226 |             expect(targetRequest.readyState).toEqual("closed")
    > 227 |             expect(serverSocket.readyState).toEqual("closed")
          |                                             ^
      228 |     });
      229 | });
      230 |

      at Object.<anonymous> (test/test.ts:227:35)

Fixes #267.
Relates microsoft/playwright#28701.

Copy link

changeset-bot bot commented Jan 8, 2024

⚠️ No Changeset found

Latest commit: ba932ac

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Jan 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
proxy-agents ✅ Ready (Inspect) Visit Preview Jan 16, 2024 0:48am

@mxschmitt mxschmitt changed the title fix: EPIPE error when socket got closed before target fix: should close both connections when client disconnects Jan 16, 2024
@mxschmitt
Copy link
Author

@TooTallNate PTAL, I'm kinda struggling creating a reliable test for it which reproduces the problem we had, but I feel like this code addition and test seems reasonable. Would appreciate if you could take a look, Thanks!

@mxschmitt mxschmitt closed this Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: EPIPE socket "error" event after "end" event
1 participant