diff --git a/patches/@libp2p__tcp@11.0.13.patch b/patches/@libp2p__tcp@11.0.13.patch new file mode 100644 index 000000000000..642b569d8d73 --- /dev/null +++ b/patches/@libp2p__tcp@11.0.13.patch @@ -0,0 +1,31 @@ +diff --git a/dist/src/socket-to-conn.js b/dist/src/socket-to-conn.js +index 2ef149718745e5901cdce459d73dcb3d4b7e596e..a8a2ba0830c4f1cb42bd555112ee01dead908c2f 100644 +--- a/dist/src/socket-to-conn.js ++++ b/dist/src/socket-to-conn.js +@@ -88,6 +88,10 @@ class TCPSocketMultiaddrConnection extends AbstractMultiaddrConnection { + await pEvent(this.socket, 'close', options); + } + sendReset() { ++ if (this.socket.writableEnded) { ++ this.socket.destroy(); ++ return; ++ } + this.socket.resetAndDestroy(); + } + sendPause() { +diff --git a/src/socket-to-conn.ts b/src/socket-to-conn.ts +index c4a085b17b6326c96b305741af6b1717cd8a2714..4fba3375008e899bb60eef0382cb4d9c6245525f 100644 +--- a/src/socket-to-conn.ts ++++ b/src/socket-to-conn.ts +@@ -123,6 +123,11 @@ class TCPSocketMultiaddrConnection extends AbstractMultiaddrConnection { + } + + sendReset (): void { ++ if (this.socket.writableEnded) { ++ this.socket.destroy() ++ return ++ } ++ + this.socket.resetAndDestroy() + } + diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 69e3f07cb168..0a767e04f49e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,7 @@ catalogs: version: 4.0.7 overrides: + '@libp2p/tcp': 11.0.13 dns-over-http-resolver: ^2.1.1 elliptic: '>=6.6.1' loupe: ^2.3.6 @@ -27,6 +28,7 @@ overrides: sigstore: 4.0.0 patchedDependencies: + '@libp2p/tcp@11.0.13': 2a9b4f4effc08a7f5869cc5d596c5eea0669ebf22d3c73f48fab474e27c39533 sigstore@4.0.0: 0d9fa39ff088202d74fca3bec0d7bc1c2822b4bddcab7cd31627235b21b52b32 importers: @@ -255,8 +257,8 @@ importers: specifier: ^5.0.14 version: 5.0.14 '@libp2p/tcp': - specifier: ^11.0.13 - version: 11.0.13 + specifier: 11.0.13 + version: 11.0.13(patch_hash=2a9b4f4effc08a7f5869cc5d596c5eea0669ebf22d3c73f48fab474e27c39533) '@lodestar/api': specifier: workspace:^ version: link:../api @@ -8020,7 +8022,7 @@ snapshots: '@libp2p/interface': 3.2.3 prom-client: 15.1.3 - '@libp2p/tcp@11.0.13': + '@libp2p/tcp@11.0.13(patch_hash=2a9b4f4effc08a7f5869cc5d596c5eea0669ebf22d3c73f48fab474e27c39533)': dependencies: '@libp2p/interface': 3.2.3 '@libp2p/utils': 7.2.2 @@ -8029,7 +8031,7 @@ snapshots: '@types/sinon': 20.0.0 main-event: 1.0.1 p-event: 7.1.0 - progress-events: 1.0.1 + progress-events: 1.1.0 uint8arraylist: 2.4.8 '@libp2p/utils@7.2.2': diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 4da3aa595218..bc3eaeaa303b 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -33,6 +33,10 @@ allowBuilds: ssh2: true overrides: + # Pin exactly while patches/@libp2p__tcp@11.0.13.patch is in place, the patch + # only applies to this version. Remove together with the patch once + # js-libp2p#3597 is released. + "@libp2p/tcp": "11.0.13" dns-over-http-resolver: "^2.1.1" elliptic: ">=6.6.1" loupe: "^2.3.6" @@ -43,4 +47,5 @@ overrides: sigstore: "4.0.0" patchedDependencies: + "@libp2p/tcp@11.0.13": patches/@libp2p__tcp@11.0.13.patch sigstore@4.0.0: patches/sigstore@4.0.0.patch