Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

refactor: remove use of timeout-abort-controller #148

Merged
merged 2 commits into from
May 3, 2023
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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@
"multihashes": "^4.0.3",
"p-defer": "^4.0.0",
"protons-runtime": "^5.0.0",
"timeout-abort-controller": "^3.0.0",
"uint8arraylist": "^2.3.3",
"uint8arrays": "^4.0.2",
"detect-browser": "^5.3.0"
Expand Down
6 changes: 2 additions & 4 deletions src/peer_transport/handler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { IncomingStreamData } from '@libp2p/interface-registrar'
import { pbStream } from 'it-pb-stream'
import pDefer, { type DeferredPromise } from 'p-defer'
import { TimeoutController } from 'timeout-abort-controller'
import { readCandidatesUntilConnected, resolveOnConnected } from './util.js'
import * as pb from './pb/index.js'
import { abortableDuplex } from 'abortable-iterator'
Expand All @@ -17,9 +16,8 @@ const log = logger('libp2p:webrtc:peer')
export type IncomingStreamOpts = { rtcConfiguration?: RTCConfiguration } & IncomingStreamData

export async function handleIncomingStream ({ rtcConfiguration, stream: rawStream }: IncomingStreamOpts): Promise<[RTCPeerConnection, StreamMuxerFactory]> {
const timeoutController = new TimeoutController(DEFAULT_TIMEOUT)
const signal = timeoutController.signal
const stream = pbStream(abortableDuplex(rawStream, timeoutController.signal)).pb(pb.Message)
const signal = AbortSignal.timeout(DEFAULT_TIMEOUT)
const stream = pbStream(abortableDuplex(rawStream, signal)).pb(pb.Message)
const pc = new RTCPeerConnection(rtcConfiguration)
const muxerFactory = new DataChannelMuxerFactory(pc)

Expand Down