-
Notifications
You must be signed in to change notification settings - Fork 502
docs: add TROUBLESHOOTING.md and extend Debugging section #3243
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
Open
Galoretka
wants to merge
3
commits into
libp2p:main
Choose a base branch
from
Galoretka:docs/add-troubleshooting-md-extend-debugging-2101
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# Troubleshooting | ||
|
||
This guide lists common issues you may encounter when running `js-libp2p`, along with steps to diagnose and resolve them using existing logs, events and configuration. | ||
|
||
## Enable debug logging | ||
|
||
- Node: | ||
|
||
```bash | ||
# all libp2p debug logs | ||
DEBUG="libp2p:*" node my-script.js | ||
|
||
# focus on connection dialing and common network components | ||
DEBUG="libp2p:connection-manager:dial-queue,libp2p:tcp,libp2p:websockets,libp2p:webtransport,libp2p:kad-dht" node my-script.js | ||
``` | ||
|
||
- Browser: | ||
|
||
```js | ||
// all libp2p debug logs | ||
localStorage.setItem('debug', 'libp2p:*') | ||
|
||
// focus on connection dialing and common network components | ||
localStorage.setItem('debug', 'libp2p:connection-manager:dial-queue,libp2p:websockets,libp2p:webtransport,libp2p:kad-dht') | ||
// then refresh the page | ||
``` | ||
|
||
Logger namespaces used by components include: | ||
|
||
- `libp2p:tcp` (`@libp2p/tcp`) | ||
- `libp2p:websockets` (`@libp2p/websockets`) | ||
- `libp2p:webtransport` (`@libp2p/webtransport`) | ||
- `libp2p:kad-dht` (`@libp2p/kad-dht`) | ||
- `libp2p:connection-manager:dial-queue` | ||
|
||
## Common issues | ||
|
||
### No transport available for address | ||
|
||
Symptoms: | ||
|
||
- Error originating from the transport manager similar to: | ||
|
||
```text | ||
No transport available for address /<proto>/... | ||
``` | ||
|
||
This occurs when you try to listen on or dial a Multiaddr for which no transport is configured. For example, `/ip4/127.0.0.1/tcp/0` requires `@libp2p/tcp`, `/ws` requires `@libp2p/websockets`, and `/webtransport` requires `@libp2p/webtransport`. | ||
|
||
Actions: | ||
|
||
- Ensure the corresponding transport is added to `transports` when creating the node. | ||
- Verify the Multiaddr protocol matches an enabled transport. | ||
- Enable component logs to see selection and listen errors: | ||
|
||
```bash | ||
DEBUG="libp2p:tcp,libp2p:websockets,libp2p:webtransport" node my-script.js | ||
``` | ||
|
||
### Address reported as not dialable / dial failed | ||
|
||
Symptoms: | ||
|
||
- Dial attempts fail with logs like: | ||
|
||
```text | ||
libp2p:connection-manager:dial-queue dial failed to <multiaddr> | ||
``` | ||
|
||
- Downstream components may log messages such as "could not dial". | ||
|
||
Actions: | ||
|
||
- Check that the peer’s addresses include a protocol supported by your configured transports. | ||
- Verify the address formatting (see next section) and that any required intermediaries (e.g. relays) are reachable. | ||
- Increase dial logs: | ||
|
||
```bash | ||
DEBUG="libp2p:connection-manager:dial-queue,libp2p:tcp,libp2p:websockets,libp2p:webtransport" node my-script.js | ||
``` | ||
|
||
### Invalid Multiaddr format | ||
|
||
Symptoms: | ||
|
||
- Errors like: | ||
|
||
```text | ||
Can't convert to IpNet, Invalid multiaddr format: <addr> | ||
``` | ||
|
||
Actions: | ||
|
||
- Validate that the string is a correct Multiaddr. Construct addresses using `@multiformats/multiaddr` where possible to avoid typos. | ||
- Ensure all required protocol parts are present (e.g. `/ip4/.../tcp/...`, `/dns4/.../tcp/.../ws`). | ||
|
||
### WebTransport cannot listen in Node.js | ||
|
||
Symptoms: | ||
|
||
- Attempting to listen using WebTransport fails. | ||
|
||
Context: | ||
|
||
- The WebTransport transport currently only supports dialing to other nodes. Listening requires QUIC support to land in Node.js first. | ||
|
||
Actions: | ||
|
||
- Use WebTransport for dialing only. For listening in Node.js, use supported server-side transports such as TCP or WebSockets. | ||
|
||
### Peer discovery does not emit events | ||
|
||
Symptoms: | ||
|
||
- You do not see `peer:discovery` or subsequent `peer:connect` events. | ||
|
||
Actions: | ||
|
||
- Ensure at least one discovery module is configured (e.g. `@libp2p/bootstrap`, `@libp2p/mdns`). | ||
- Listen for events to verify activity: | ||
|
||
```ts | ||
node.addEventListener('peer:discovery', (evt) => { | ||
console.log('Discovered', evt.detail.id.toString()) | ||
}) | ||
|
||
node.addEventListener('peer:connect', (evt) => { | ||
console.log('Connected to', evt.detail.toString()) | ||
}) | ||
``` | ||
|
||
- Enable discovery-related logs (for example, DHT and transports) to see find/dial attempts: | ||
|
||
```bash | ||
DEBUG="libp2p:kad-dht,libp2p:tcp,libp2p:websockets,libp2p:webtransport" node my-script.js | ||
``` | ||
|
||
## See also | ||
|
||
- `doc/GETTING_STARTED.md` Debugging section for quick debug setup | ||
- `doc/CONFIGURATION.md` for full configuration options | ||
- `doc/API.md` Events section (`peer:discovery`, `peer:connect`) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct - WebTransport is not supported at all in Node.js right now.
Where did this information come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, updated doc