Open
Description
Description
Currently in packages/tests/src/utils/nodes.ts
, we're using arbitrary delays (await delay(2000)
) to ensure proper node setup and connection. These delays were added as a temporary fix to make tests pass, but they are not ideal as:
- They make tests slower than necessary
- They don't guarantee that the system is actually ready (could be too short in some cases)
- They might be unnecessarily long in other cases
- They make the tests less deterministic and reliable
Instead of using arbitrary delays, we should investigate implementing proper wait mechanisms based on specific log lines or node states.
Expected Behavior
The node setup and connection process should:
- Use deterministic waiting mechanisms based on actual node states or specific log lines
- Only wait as long as necessary for each operation
- Fail fast with clear error messages when expected states aren't reached
- Be reliable across different environments and network conditions
Steps to Reproduce
Current problematic code locations:
-
In
packages/tests/src/utils/nodes.ts
:// First delay after waku node creation await delay(2000); for (const node of serviceNodes.nodes) { await waku.dial(await node.getMultiaddrWithId()); await waku.waitForPeers([Protocols.Filter, Protocols.LightPush]); const success = await node.ensureSubscriptions(...); // Second delay before waiting for log await delay(2000); await node.waitForLog(waku.libp2p.peerId.toString(), 100); }
-
Run tests with
npm test
in the packages/tests directory -
Tests pass but take longer than necessary due to fixed delays
Environment Details
- js-waku packages version: latest
- nwaku version: 0.34.0
Investigation Points
-
After waku node creation:
- What specific state/log lines indicate the node is fully ready?
- Can we use
waitForLog
with specific startup completion indicators?
-
Before waiting for peer logs:
- What conditions need to be met before checking for peer logs?
- Are there specific log lines or node states we can wait for?
- Why is the current 100ms timeout for
waitForLog
insufficient without the delay?
-
Potential solutions to investigate:
- Extend
waitForLog
to support multiple log lines in sequence - Add new wait mechanisms based on node state rather than logs
- Implement proper retry mechanisms with backoff instead of fixed delays
- Add more detailed logging to help identify exact ready states
- Extend
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
To Do