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

Commit

Permalink
refactor: remove use of timeout-abort-controller (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
maschad committed May 3, 2023
1 parent 68b446d commit 0a72552
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
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

0 comments on commit 0a72552

Please sign in to comment.