Skip to content
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
be51d56
chore: firefox webrtc
achingbrain Sep 9, 2025
d9cf155
chore: ignore yamux trace
achingbrain Sep 9, 2025
ae357cf
chore: log stream id
achingbrain Sep 9, 2025
8ff70ce
chore: log stream id
achingbrain Sep 9, 2025
852e941
chore: more log
achingbrain Sep 9, 2025
ed0d84d
chore: do not mark read closed unless closed
achingbrain Sep 9, 2025
6dc660a
chore: log read closure reason
achingbrain Sep 9, 2025
d6e56bb
chore: where message?
achingbrain Sep 9, 2025
558ff7e
chore: update log
achingbrain Sep 9, 2025
6b2b96f
chore: update log
achingbrain Sep 9, 2025
09da1eb
chore: try delay
achingbrain Sep 9, 2025
6ab7942
chore: remove timeout
achingbrain Sep 9, 2025
061d657
chore: rejig channel close
achingbrain Sep 9, 2025
2ce4f5c
chore: rejig channel close
achingbrain Sep 9, 2025
a783ce8
chore: rejig channel close
achingbrain Sep 9, 2025
014ad71
chore: try not closing
achingbrain Sep 9, 2025
12f42ea
chore: let initiator close channel
achingbrain Sep 9, 2025
82fdf3e
chore: let initiator close channel
achingbrain Sep 9, 2025
4652eab
chore: ff
achingbrain Sep 9, 2025
885d517
chore: ff
achingbrain Sep 9, 2025
d8cd161
chore: ff
achingbrain Sep 9, 2025
b650235
chore: ff
achingbrain Sep 9, 2025
ce709fd
chore: ff
achingbrain Sep 9, 2025
05ce97e
chore: try remove ff detection
achingbrain Sep 9, 2025
95a5990
chore: ff
achingbrain Sep 9, 2025
c9cdf33
chore: ff
achingbrain Sep 10, 2025
545e4e3
chore: ff
achingbrain Sep 10, 2025
b069162
chore: ff
achingbrain Sep 10, 2025
660d59b
chore: ff
achingbrain Sep 10, 2025
ec4f73e
chore: ff
achingbrain Sep 10, 2025
a728b64
chore: ff
achingbrain Sep 10, 2025
98c8569
chore: ff
achingbrain Sep 10, 2025
263b746
chore: log sent amount
achingbrain Sep 10, 2025
b09f2a5
chore: ff
achingbrain Sep 10, 2025
daefd63
chore: ff
achingbrain Sep 10, 2025
22e9a90
chore: ff
achingbrain Sep 10, 2025
3c60b0d
chore: ff
achingbrain Sep 10, 2025
8f4914d
chore: ff
achingbrain Sep 10, 2025
2aa163d
chore: ff
achingbrain Sep 10, 2025
1c325b8
chore: ff
achingbrain Sep 11, 2025
d6c790e
chore: ff
achingbrain Sep 11, 2025
db56b0b
chore: wait for init channel to close
achingbrain Sep 12, 2025
ed68503
chore: close channel
achingbrain Sep 12, 2025
71984fc
chore: close on remote reset
achingbrain Sep 12, 2025
1ecd982
chore: ff
achingbrain Sep 16, 2025
32f1a8b
chore: upgrade ff
achingbrain Sep 16, 2025
091caa1
chore: restore code
achingbrain Sep 16, 2025
15dfd3b
Merge branch 'main' into chore/firefox-webrtc
achingbrain Sep 16, 2025
e8baed0
chore: linting
achingbrain Sep 16, 2025
2866f7d
chore: deps
achingbrain Sep 16, 2025
95e5d3a
chore: ff
achingbrain Sep 16, 2025
b4412eb
chore: linting
achingbrain Sep 16, 2025
e1df0bb
chore: close ping
achingbrain Sep 16, 2025
cda3fa5
chore: linting
achingbrain Sep 16, 2025
bd34500
chore: fin ack
achingbrain Sep 16, 2025
47e51cd
chore: handle promise
achingbrain Sep 16, 2025
7955a60
chore: linting
achingbrain Sep 16, 2025
1451375
chore: chrome
achingbrain Sep 17, 2025
30d5950
chore: dep
achingbrain Sep 17, 2025
b835442
chore: filter by protocol
achingbrain Sep 17, 2025
a3c3107
chore: events
achingbrain Sep 17, 2025
40b2dfd
chore: channel open
achingbrain Sep 17, 2025
cafb7e5
chore: linting
achingbrain Sep 17, 2025
23dbd53
chore: slow ci is slow
achingbrain Sep 17, 2025
9274350
chore: update aegir
achingbrain Sep 17, 2025
58f8d1f
chore: disable fin_ack
achingbrain Sep 17, 2025
8b23f3b
chore: deps
achingbrain Sep 17, 2025
7e9ed74
chore: hack for node-datachannel
achingbrain Sep 18, 2025
459f30d
chore: receive data
achingbrain Sep 18, 2025
eff8ff9
chore: receive data
achingbrain Sep 18, 2025
cf23525
chore: linting
achingbrain Sep 18, 2025
6acb0c7
chore: rust is broken
achingbrain Sep 18, 2025
f2b8675
chore: wat
achingbrain Sep 18, 2025
225874c
chore: finack
achingbrain Sep 18, 2025
b6acd87
chore: chrome y u no exit
achingbrain Sep 18, 2025
81902af
chore: hang
achingbrain Sep 18, 2025
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: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@
"doc",
"interop",
"packages/*"
]
],
"overrides": {
"playwright-core": "next"
}
}
2 changes: 2 additions & 0 deletions packages/integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"lint": "aegir lint",
"test:chrome": "aegir test -t browser --cov",
"test:chrome-webworker": "aegir test -t webworker",
"test:firefox": "aegir test -t browser -- --browser firefox",
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
"test:node": "aegir test -t node -f dist/test/node.js -f dist/test/**/*.spec.js --cov -- --exit",
"test:interop": "aegir test -t node -f dist/test/interop.js",
"dep-check": "aegir dep-check"
Expand Down
7 changes: 2 additions & 5 deletions packages/integration-tests/test/bootstrap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@ describe('bootstrap', () => {
let libp2p: Libp2p

beforeEach(async () => {
[remotePeerId1, remotePeerId2] = await Promise.all([
peerIdFromPrivateKey(await generateKeyPair('Ed25519')),
peerIdFromPrivateKey(await generateKeyPair('Ed25519')),
peerIdFromPrivateKey(await generateKeyPair('Ed25519'))
])
remotePeerId1 = peerIdFromPrivateKey(await generateKeyPair('Ed25519'))
remotePeerId2 = peerIdFromPrivateKey(await generateKeyPair('Ed25519'))
})

afterEach(async () => {
Expand Down
38 changes: 18 additions & 20 deletions packages/integration-tests/test/dht.node.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-env mocha */

import { identify } from '@libp2p/identify'
import { start, stop } from '@libp2p/interface'
import { kadDHT, passthroughMapper } from '@libp2p/kad-dht'
import { mplex } from '@libp2p/mplex'
import { ping } from '@libp2p/ping'
Expand Down Expand Up @@ -97,10 +98,10 @@ describe('DHT subsystem operates correctly', () => {
}
})

await Promise.all([
libp2p.start(),
remoteLibp2p.start()
])
await start(
libp2p,
remoteLibp2p
)

await libp2p.peerStore.patch(remoteLibp2p.peerId, {
multiaddrs: [remoteListenAddr]
Expand All @@ -109,13 +110,10 @@ describe('DHT subsystem operates correctly', () => {
})

afterEach(async () => {
if (libp2p != null) {
await libp2p.stop()
}

if (remoteLibp2p != null) {
await remoteLibp2p.stop()
}
await stop(
libp2p,
remoteLibp2p
)
})

it('should get notified of connected peers on dial', async () => {
Expand Down Expand Up @@ -186,11 +184,11 @@ describe('DHT subsystem operates correctly', () => {
}
})

await Promise.all([
libp2p.start(),
remoteLibp2p1.start(),
remoteLibp2p2.start()
])
await start(
libp2p,
remoteLibp2p1,
remoteLibp2p2
)

await libp2p.peerStore.patch(remoteLibp2p1.peerId, {
multiaddrs: remoteLibp2p1.getMultiaddrs()
Expand All @@ -208,9 +206,9 @@ describe('DHT subsystem operates correctly', () => {
])

await deferred.promise
return Promise.all([
remoteLibp2p1.stop(),
remoteLibp2p2.stop()
])
return stop(
remoteLibp2p1,
remoteLibp2p2
)
})
})
4 changes: 2 additions & 2 deletions packages/integration-tests/test/events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ describe('events', () => {
await dialer.dial(listener.getMultiaddrs())

// Verify onConnection is called with the connection
const connections = await Promise.all([
const connections = [
...dialer.getConnections(listener.peerId),
...listener.getConnections(dialer.peerId)
])
]
expect(connections).to.have.lengthOf(2)

await Promise.all([
Expand Down
17 changes: 10 additions & 7 deletions packages/integration-tests/test/mdns.node.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-env mocha */

import { randomBytes } from '@libp2p/crypto'
import { start, stop } from '@libp2p/interface'
import { mdns } from '@libp2p/mdns'
import { tcp } from '@libp2p/tcp'
import { multiaddr } from '@multiformats/multiaddr'
Expand Down Expand Up @@ -70,15 +71,17 @@ describe('mdns', () => {
}
})

await Promise.all([
remoteLibp2p1.start(),
remoteLibp2p2.start(),
libp2p.start()
])
await start(
remoteLibp2p1,
remoteLibp2p2,
libp2p
)

await deferred.promise

await remoteLibp2p1.stop()
await remoteLibp2p2.stop()
await stop(
remoteLibp2p1,
remoteLibp2p2
)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ export default (common: TestSetup<StreamMuxerFactory>): void => {

await Promise.all([
pEvent(listenerStream, 'close'),
// eslint-disable-next-line @typescript-eslint/await-thenable
dialerStream.abort(new Error('Urk!'))
])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ export default (common: TestSetup<StreamMuxerFactory>): void => {

await Promise.all([
pEvent(outboundStream, 'close'),
// eslint-disable-next-line @typescript-eslint/await-thenable
inboundStream.abort(new Error('Urk!'))
])

Expand Down
10 changes: 6 additions & 4 deletions packages/interface-compliance-tests/src/transport/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export default (common: TestSetup<TransportTestFixtures>): void => {
.with.property('name', 'AbortError')
})

it('should close all streams when the connection closes', async () => {
it.only('should close all streams when the connection closes', async () => {
({ dialer, listener, dialAddrs, listenMultiaddrMatcher } = await getSetup(common))

let incomingConnectionPromise: PromiseWithResolvers<Connection> | undefined
Expand Down Expand Up @@ -250,8 +250,9 @@ export default (common: TestSetup<TransportTestFixtures>): void => {
expect(connection).to.have.property('streams').that.has.lengthOf(5)

if (remoteConn != null) {
await pWaitFor(() => remoteConn.streams.length === 5, {
timeout: 5000
await pWaitFor(() => remoteConn.streams.filter(s => s.protocol === '/echo/1.0.0').length === 5, {
timeout: 5_000,
interval: 1_000
})
}

Expand Down Expand Up @@ -360,7 +361,8 @@ export default (common: TestSetup<TransportTestFixtures>): void => {
const connection = await dialer.dial(dialAddrs[0])
const echoProtocol = dialer.services.echo.protocol

for (let i = 0; i < 2000; i++) {
// TODO: increase this back to 2_000
for (let i = 0; i < 1_000; i++) {
const input = new Uint8Array(1024).fill(5)
const output = await dialer.services.echo.echo(connection.remotePeer, input, {
signal: AbortSignal.timeout(timeout)
Expand Down
2 changes: 1 addition & 1 deletion packages/interface/src/stream-muxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export interface StreamMuxer<MuxedStream extends Stream = Stream> extends TypedE
/**
* Create a new stream
*/
createStream(options?: CreateStreamOptions): MuxedStream | Promise<MuxedStream>
createStream(options?: CreateStreamOptions): Promise<MuxedStream>

/**
* Immediately close the muxer, abort every open stream and discard any
Expand Down
2 changes: 1 addition & 1 deletion packages/libp2p/src/libp2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export class Libp2p<T extends ServiceMap = ServiceMap> extends TypedEventEmitter

this.status = 'started'
this.safeDispatchEvent('start', { detail: this })
this.log('libp2p has started')
this.log('libp2p has started with peer id %p', this.peerId)
} catch (err: any) {
this.log.error('An error occurred starting libp2p', err)
// set status to 'started' so this.stop() will stop any running components
Expand Down
4 changes: 2 additions & 2 deletions packages/libp2p/test/upgrading/upgrader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ describe('upgrader', () => {
protocol: muxerProtocol,
createStreamMuxer: () => stubInterface<StreamMuxer>({
status: 'open',
createStream: () => {
createStream: async () => {
return outboundStream
}
})
Expand Down Expand Up @@ -422,7 +422,7 @@ describe('upgrader', () => {
protocol: muxerProtocol,
createStreamMuxer: () => stubInterface<StreamMuxer>({
status: 'open',
createStream: () => {
createStream: async () => {
return outboundStream
}
})
Expand Down
28 changes: 27 additions & 1 deletion packages/logger/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,33 @@ debug.formatters.a = (v?: Multiaddr): string => {

// Add a formatter for stringifying Errors
debug.formatters.e = (v?: Error): string => {
return v == null ? 'undefined' : notEmpty(v.stack) ?? notEmpty(v.message) ?? v.toString()
if (v == null) {
return 'undefined'
}

const message = notEmpty(v.message)
const stack = notEmpty(v.stack)

// some browser errors (mostly from Firefox) have no message or no stack,
// sometimes both, sometimes neither. Sometimes the message is in the stack,
// sometimes is isn't so try to do *something* useful
if (message != null && stack != null) {
if (stack.includes(message)) {
return stack
}

return `${message}\n${stack}`
}

if (stack != null) {
return stack
}

if (message != null) {
return message
}

return v.toString()
}

export type { Logger, ComponentLogger }
Expand Down
8 changes: 3 additions & 5 deletions packages/peer-discovery-mdns/test/multicast-dns.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ describe('MulticastDNS', () => {
before(async function () {
this.timeout(80 * 1000)

;[pA, pB, pD] = await Promise.all([
peerIdFromPrivateKey(await generateKeyPair('Ed25519')),
peerIdFromPrivateKey(await generateKeyPair('Ed25519')),
peerIdFromPrivateKey(await generateKeyPair('Ed25519'))
])
pA = peerIdFromPrivateKey(await generateKeyPair('Ed25519'))
pB = peerIdFromPrivateKey(await generateKeyPair('Ed25519'))
pD = peerIdFromPrivateKey(await generateKeyPair('Ed25519'))

aMultiaddrs = [
multiaddr('/ip4/192.168.1.142/tcp/20001'),
Expand Down
8 changes: 7 additions & 1 deletion packages/protocol-ping/src/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ export class Ping implements Startable, PingInterface {
if (!uint8ArrayEquals(data, received.subarray())) {
finished.reject(new ProtocolError(`Received wrong ping ack after ${rtt}ms`))
} else {
finished.resolve(rtt)
stream.closeRead(options)
.then(() => {
finished.resolve(rtt)
})
.catch(err => {
stream.abort(err)
})
}
}
})
Expand Down
5 changes: 5 additions & 0 deletions packages/stream-multiplexer-mplex/test/stream.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ describe('stream', () => {

const [evt] = await Promise.all([
pEvent<'close', StreamCloseEvent>(pair.initiatorStream, 'close'),
// eslint-disable-next-line @typescript-eslint/await-thenable
pair.initiatorStream.abort(error)
])

Expand Down Expand Up @@ -270,6 +271,7 @@ describe('stream', () => {

await Promise.all([
pEvent(pair.receiverStream, 'close'),
// eslint-disable-next-line @typescript-eslint/await-thenable
pair.initiatorStream.abort(error)
])

Expand Down Expand Up @@ -301,6 +303,7 @@ describe('stream', () => {

await Promise.all([
pEvent(pair.initiatorStream, 'close'),
// eslint-disable-next-line @typescript-eslint/await-thenable
pair.receiverStream.abort(error)
])

Expand Down Expand Up @@ -442,6 +445,7 @@ describe('stream', () => {

await Promise.all([
pEvent(pair.receiverStream, 'close'),
// eslint-disable-next-line @typescript-eslint/await-thenable
pair.initiatorStream.abort(new Error('wat'))
])

Expand Down Expand Up @@ -493,6 +497,7 @@ describe('stream', () => {

await Promise.all([
pEvent(pair.initiatorStream, 'close'),
// eslint-disable-next-line @typescript-eslint/await-thenable
pair.receiverStream.abort(new Error('wat'))
])

Expand Down
3 changes: 1 addition & 2 deletions packages/transport-circuit-relay-v2/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const DEFAULT_RESERVATION_CONCURRENCY = 1
/**
* How long to wait for a reservation attempt to finish
*/
export const DEFAULT_RESERVATION_COMPLETION_TIMEOUT = 2000
export const DEFAULT_RESERVATION_COMPLETION_TIMEOUT = 5_000

/**
* How long to let the reservation attempt queue to grow
Expand All @@ -31,7 +31,6 @@ export const DEFAULT_MAX_RESERVATION_QUEUE_LENGTH = 100
export const RELAY_SOURCE_TAG = 'circuit-relay-source'

export const KEEP_ALIVE_TAG = `${KEEP_ALIVE}-circuit-relay`
export const KEEP_ALIVE_SOURCE_TAG = `${KEEP_ALIVE}-circuit-relay-source`

// circuit v2 connection limits
// https://github.com/libp2p/go-libp2p/blob/master/p2p/protocol/circuitv2/relay/resources.go#L61-L66
Expand Down
7 changes: 2 additions & 5 deletions packages/transport-circuit-relay-v2/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { TypedEventEmitter, setMaxListeners } from 'main-event'
import * as Digest from 'multiformats/hashes/digest'
import {
DEFAULT_HOP_TIMEOUT,
KEEP_ALIVE_SOURCE_TAG,
MAX_CONNECTIONS,
RELAY_SOURCE_TAG,
RELAY_V2_HOP_CODEC,
Expand Down Expand Up @@ -188,8 +187,7 @@ export class CircuitRelayServer extends TypedEventEmitter<RelayServerEvents> imp
const ttl = (result.expire * 1000) - Date.now()
await this.components.peerStore.merge(connection.remotePeer, {
tags: {
[RELAY_SOURCE_TAG]: { value: 1, ttl },
[KEEP_ALIVE_SOURCE_TAG]: { value: 1, ttl }
[RELAY_SOURCE_TAG]: { value: 1, ttl }
}
}, options)
}
Expand All @@ -211,8 +209,7 @@ export class CircuitRelayServer extends TypedEventEmitter<RelayServerEvents> imp
try {
await this.components.peerStore.merge(connection.remotePeer, {
tags: {
[RELAY_SOURCE_TAG]: undefined,
[KEEP_ALIVE_SOURCE_TAG]: undefined
[RELAY_SOURCE_TAG]: undefined
}
}, options)
} catch (err) {
Expand Down
Loading
Loading