Skip to content

Commit

Permalink
fix: pass abort signal to dial
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Feb 24, 2025
1 parent 2be16e0 commit 05cb100
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/libp2p-daemon-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ class Client implements DaemonClient {
* @async
* @returns {MultiaddrConnection}
*/
async connectDaemon (): Promise<MultiaddrConnection> {
async connectDaemon (signal?: AbortSignal): Promise<MultiaddrConnection> {
// @ts-expect-error because we use a passthrough upgrader,
// this is actually a MultiaddrConnection and not a Connection
return this.tcp.dial(this.multiaddr, {
upgrader: new PassThroughUpgrader()
upgrader: new PassThroughUpgrader(),
signal: signal ?? AbortSignal.timeout(10_000)
})
}

Expand Down
3 changes: 2 additions & 1 deletion packages/libp2p-daemon-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ export class Server implements Libp2pServer {
// @ts-expect-error because we use a passthrough upgrader,
// this is actually a MultiaddrConnection and not a Connection
conn = await this.tcp.dial(addr, {
upgrader: new PassThroughUpgrader()
upgrader: new PassThroughUpgrader(),
signal: AbortSignal.timeout(10_000)
})

const message = StreamInfo.encode({
Expand Down

0 comments on commit 05cb100

Please sign in to comment.