From f9106296b97a025ad366f0414defed655b8dce41 Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Tue, 29 Sep 2026 12:41:45 +0000 Subject: [PATCH] sdk/js: cite the js-libp2p issues behind the relay workarounds listenThroughRelay reaches the transport manager because js-libp2p has no public way to listen on an address after start(), and keepRelay reserves again because a static relay reservation is not re-established after the connection dropped. Both are filed upstream: libp2p/js-libp2p#3645 and libp2p/js-libp2p#3601. Name them where the code works around them, as the Python SDK does for py-libp2p, so that an upstream fix can be matched to the code it makes unnecessary. --- sdk/README.md | 12 ++++++++---- sdk/js/src/host.ts | 2 ++ sdk/js/src/session.ts | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/sdk/README.md b/sdk/README.md index f18855b1..b83d595e 100644 --- a/sdk/README.md +++ b/sdk/README.md @@ -92,14 +92,18 @@ pinned by a test: - js-libp2p reserves a relay slot when it starts listening on `/p2p-circuit`, and a router refuses that before the auth handshake. The JS SDK starts the listener after the handshake, through the - transport manager, which is not on the public `Libp2p` interface. + transport manager, which is not on the public `Libp2p` interface + ([libp2p/js-libp2p#3645](https://github.com/libp2p/js-libp2p/issues/3645)). - go-libp2p's relay grants a reservation for one hour and drops it when that passes, and with the connection it was made on; a member that still advertises the relayed address is then unreachable (`NO_RESERVATION`). js-libp2p's listener renews on its own, but only on a connection the - router still holds the admission of; the JS SDK runs the handshake again - on every new connection to a router and, when the relayed address is - gone, authenticates and reserves again within thirty seconds. The Python + router still holds the admission of, and does not reserve again on a + static relay after the connection dropped + ([libp2p/js-libp2p#3601](https://github.com/libp2p/js-libp2p/issues/3601)); + the JS SDK runs the handshake again on every new connection to a router + and, when the relayed address is gone, authenticates and reserves again + within thirty seconds. The Python SDK renews two minutes before the expiry the router returned, and within thirty seconds of the connection to that router going, running the auth handshake again first. diff --git a/sdk/js/src/host.ts b/sdk/js/src/host.ts index c33cd357..32693947 100644 --- a/sdk/js/src/host.ts +++ b/sdk/js/src/host.ts @@ -105,6 +105,8 @@ export interface RelayListener { * restarts or trims the connection drops it, and js-libp2p does not ask a * configured relay again. Calling `listen` on the returned listener does, * without registering a second listener. + * + * Upstream: libp2p/js-libp2p#3645 (listen after start), #3601 (re-reserve). */ export async function listenThroughRelay(node: Libp2p, relayAddr: Multiaddr): Promise { const internals = node as unknown as { components: { transportManager: { listen(addrs: Multiaddr[]): Promise; getListeners(): RelayListener[] } } }; diff --git a/sdk/js/src/session.ts b/sdk/js/src/session.ts index 5274fbb1..cae0437e 100644 --- a/sdk/js/src/session.ts +++ b/sdk/js/src/session.ts @@ -251,7 +251,7 @@ export class MeshSession { * tried in order, each dialed and authenticated again first, since the * router forgot the admission with the connection. Runs on * relayCheckIntervalMs; exposed so a caller can force it. Concurrent - * calls share one attempt. + * calls share one attempt. Upstream: libp2p/js-libp2p#3601. */ keepRelay(): Promise { this.#keepingRelay ??= this.#keepRelayOnce().finally(() => {