Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-trace-function-to-metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain authored Jan 7, 2025
2 parents 086c5c5 + 7701438 commit 712d139
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"packages/auto-tls":"1.0.2","packages/config":"1.0.0","packages/connection-encrypter-plaintext":"2.0.12","packages/connection-encrypter-tls":"2.0.12","packages/crypto":"5.0.8","packages/interface":"2.3.0","packages/interface-compliance-tests":"6.2.2","packages/interface-internal":"2.2.1","packages/kad-dht":"14.1.6","packages/keychain":"5.0.11","packages/libp2p":"2.4.2","packages/logger":"5.1.5","packages/metrics-devtools":"1.1.12","packages/metrics-prometheus":"4.2.10","packages/metrics-simple":"1.2.8","packages/multistream-select":"6.0.10","packages/peer-collections":"6.0.13","packages/peer-discovery-bootstrap":"11.0.16","packages/peer-discovery-mdns":"11.0.16","packages/peer-id":"5.0.9","packages/peer-record":"8.0.13","packages/peer-store":"11.0.13","packages/pnet":"2.0.16","packages/protocol-autonat":"2.0.15","packages/protocol-dcutr":"2.0.14","packages/protocol-echo":"2.1.5","packages/protocol-fetch":"2.0.14","packages/protocol-identify":"3.0.14","packages/protocol-perf":"4.0.16","packages/protocol-ping":"2.0.14","packages/pubsub":"10.0.14","packages/pubsub-floodsub":"10.1.14","packages/record":"4.0.4","packages/stream-multiplexer-mplex":"11.0.16","packages/transport-circuit-relay-v2":"3.1.6","packages/transport-memory":"1.0.2","packages/transport-tcp":"10.0.14","packages/transport-webrtc":"5.0.22","packages/transport-websockets":"9.1.0","packages/transport-webtransport":"5.0.21","packages/upnp-nat":"3.0.3","packages/utils":"6.3.0"}
{"packages/auto-tls":"1.0.2","packages/config":"1.0.0","packages/connection-encrypter-plaintext":"2.0.12","packages/connection-encrypter-tls":"2.0.12","packages/crypto":"5.0.8","packages/interface":"2.3.0","packages/interface-compliance-tests":"6.2.2","packages/interface-internal":"2.2.1","packages/kad-dht":"14.1.6","packages/keychain":"5.0.11","packages/libp2p":"2.4.2","packages/logger":"5.1.5","packages/metrics-devtools":"1.1.12","packages/metrics-prometheus":"4.2.10","packages/metrics-simple":"1.2.8","packages/multistream-select":"6.0.10","packages/peer-collections":"6.0.13","packages/peer-discovery-bootstrap":"11.0.16","packages/peer-discovery-mdns":"11.0.16","packages/peer-id":"5.0.9","packages/peer-record":"8.0.13","packages/peer-store":"11.0.13","packages/pnet":"2.0.16","packages/protocol-autonat":"2.0.15","packages/protocol-dcutr":"2.0.14","packages/protocol-echo":"2.1.5","packages/protocol-fetch":"2.0.14","packages/protocol-identify":"3.0.14","packages/protocol-perf":"4.0.16","packages/protocol-ping":"2.0.14","packages/pubsub":"10.0.14","packages/pubsub-floodsub":"10.1.14","packages/record":"4.0.4","packages/stream-multiplexer-mplex":"11.0.16","packages/transport-circuit-relay-v2":"3.1.6","packages/transport-memory":"1.0.2","packages/transport-tcp":"10.0.14","packages/transport-webrtc":"5.0.22","packages/transport-websockets":"9.1.1","packages/transport-webtransport":"5.0.21","packages/upnp-nat":"3.0.3","packages/utils":"6.3.0"}
7 changes: 7 additions & 0 deletions packages/transport-websockets/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@
* devDependencies
* @libp2p/interface-compliance-tests bumped from ^5.3.0 to ^5.3.1

## [9.1.1](https://github.com/libp2p/js-libp2p/compare/websockets-v9.1.0...websockets-v9.1.1) (2025-01-06)


### Bug Fixes

* return empty address list during listen operation ([#2904](https://github.com/libp2p/js-libp2p/issues/2904)) ([ae75570](https://github.com/libp2p/js-libp2p/commit/ae75570c852fa9bfe00910dca1c219fa585dcb83)), closes [#2902](https://github.com/libp2p/js-libp2p/issues/2902)

## [9.1.0](https://github.com/libp2p/js-libp2p/compare/websockets-v9.0.13...websockets-v9.1.0) (2024-12-09)


Expand Down
2 changes: 1 addition & 1 deletion packages/transport-websockets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@libp2p/websockets",
"version": "9.1.0",
"version": "9.1.1",
"description": "JavaScript implementation of the WebSockets module that libp2p uses and that implements the interface-transport spec",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/transport-websockets#readme",
Expand Down
10 changes: 5 additions & 5 deletions packages/transport-websockets/src/listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,20 +341,20 @@ export class WebSocketListener extends TypedEventEmitter<ListenerEvents> impleme
}

getAddrs (): Multiaddr[] {
if (this.listeningMultiaddr == null) {
throw new Error('Listener is not ready yet')
}

const address = this.server.address()

if (address == null) {
throw new Error('Listener is not ready yet')
return []
}

if (typeof address === 'string') {
throw new Error('Wrong address type received - expected AddressInfo, got string - are you trying to listen on a unix socket?')
}

if (this.listeningMultiaddr == null) {
throw new Error('Listener is not ready yet')
}

const options = this.listeningMultiaddr.toOptions()
const multiaddrs: Multiaddr[] = []

Expand Down
16 changes: 16 additions & 0 deletions packages/transport-websockets/test/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ describe('listen', () => {
void listener.listen(ma)
})

it('should return an empty address list when `getAddrs` called before listening has finished', async () => {
listener = ws.createListener({ upgrader })

void listener.listen(ma)

// call getAddrs before sockets have opened
expect(listener.getAddrs()).to.be.empty()
})

it('should throw when `.getAddrs` called before `.listen`', async () => {
listener = ws.createListener({ upgrader })

// call getAddrs before sockets have opened
expect(() => listener.getAddrs()).to.throw(/not ready/)
})

it('should error on starting two listeners on same address', async () => {
listener = ws.createListener({ upgrader })
const dumbServer = http.createServer()
Expand Down

0 comments on commit 712d139

Please sign in to comment.