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: pass abort signal to dial #285

Merged
merged 2 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading