Skip to content

Commit c30a9dc

Browse files
authored
Fix compatibility with Node.js 14 (#104)
If the socket is writable, a write is attempted and an `ERR_SOCKET_CLOSED` error is emitted because the socket was never connected. Refs: nodejs/node#32272
1 parent 3d2981c commit c30a9dc

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [ubuntu-latest, macos-latest, windows-latest]
18-
node-version: [6.x, 8.x, 10.x, 12.x]
18+
node-version: [6.x, 8.x, 10.x, 12.x, 14.x]
1919

2020
runs-on: ${{ matrix.os }}
2121

src/agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export default class HttpsProxyAgent extends Agent {
162162
// See: https://hackerone.com/reports/541502
163163
socket.destroy();
164164

165-
const fakeSocket = new net.Socket();
165+
const fakeSocket = new net.Socket({ writable: false });
166166
fakeSocket.readable = true;
167167

168168
// Need to wait for the "socket" event to re-play the "data" events.

0 commit comments

Comments
 (0)