Skip to content

fix: p2p test hang due to hang on port#165

Merged
louisliu2048 merged 2 commits intomainfrom
vui-chee/fix-p2p-test-clocking-out
Mar 3, 2026
Merged

fix: p2p test hang due to hang on port#165
louisliu2048 merged 2 commits intomainfrom
vui-chee/fix-p2p-test-clocking-out

Conversation

@Vui-Chee
Copy link
Contributor

@Vui-Chee Vui-Chee commented Mar 2, 2026

Happens when running devnet locally, just make test find next free port.

Happens when we run devnet. Find next free port
and execute request send with timeout.
if let Ok(Some(received)) =
tokio::time::timeout(Duration::from_millis(200), rx.recv()).await
{
return received;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If tx2 is a bounded channel and the connection hasn't been established yet, repeated send(...).unwrap() inside the loop could panic when the channel fills up. Either use try_send and handle the full-channel case, or wait for the connection to complete before entering the send loop.

@JimmyShi22
Copy link
Contributor

The above comments are all within test code, so feel free to address them however works best — or leave them if the tradeoffs are acceptable for a test-only context. No blockers from my side.

JimmyShi22
JimmyShi22 approved these changes Mar 2, 2026
@Vui-Chee Vui-Chee changed the title fix: p2p test hang due to port hold up fix: p2p test hang due to hang on port Mar 3, 2026
- Fix TOCTOU race by binding both listeners simultaneously and holding
  them as guards until right before node construction
- Add max retry count (100) for distinct port selection instead of
  unbounded loop
- Use try_send instead of send().unwrap() to avoid panicking when the
  channel is full before connection is established
@louisliu2048 louisliu2048 merged commit cb23948 into main Mar 3, 2026
@Vui-Chee Vui-Chee deleted the vui-chee/fix-p2p-test-clocking-out branch March 3, 2026 03:22
Vui-Chee added a commit that referenced this pull request Mar 9, 2026
* main:
  Feat(chainspec): adding xlayer-devnet chainspec (#167)
  chore(builder): flatten flashblocks builder, remove unnecessary trait interfaces (#172)
  rpc: remove unnecessary trait bounds and dependencies from XlayerRpcExtApiServer impl (#171)
  fix fmt in bin/tools/gen_genesis.rs (#170)
  fix(builder): Resolve bugs on upstream flashblocks timing scheduler (#169)
  Feat(tools): Add a tool to generate a custom genesis file based on a template and existing chain data (#159)
  feat(flashblocks): Add flashblocks sequence persistence logic on RPC and sequence replay flashblock builder (#162)
  chore(builder): remove unused custom-engine-api feature flag in tests (#168)
  fix: p2p test hang due to hang on port (#165)
Vui-Chee added a commit that referenced this pull request Mar 13, 2026
* main: (25 commits)
  fix: bump quinn-proto to 0.11.14 to patch CVE-2026-31812 DoS vuln (#183)
  pre-job authorization (#193)
  fix: trigger review skill failed to ack (#192)
  feat: trigger skill review separately (#191)
  feat: add Claude skills and CLAUDE.md for AI-assisted development (#190)
  rename ext (#185)
  supply workflow for claude (#184)
  feat(builder): incremental trie cache optimization for flashblocks state root (#163)
  chore(flashblocks-rpc): migrate op-reth flashblocks into xlayer-reth (#175)
  Feat(chainspec): adding xlayer-devnet chainspec (#167)
  chore(builder): flatten flashblocks builder, remove unnecessary trait interfaces (#172)
  rpc: remove unnecessary trait bounds and dependencies from XlayerRpcExtApiServer impl (#171)
  fix fmt in bin/tools/gen_genesis.rs (#170)
  fix(builder): Resolve bugs on upstream flashblocks timing scheduler (#169)
  Feat(tools): Add a tool to generate a custom genesis file based on a template and existing chain data (#159)
  feat(flashblocks): Add flashblocks sequence persistence logic on RPC and sequence replay flashblock builder (#162)
  chore(builder): remove unused custom-engine-api feature flag in tests (#168)
  fix: p2p test hang due to hang on port (#165)
  fix: update testcontainers to v0.27.0 to remediate CVE-2025-62518 (#164)
  chore(builder): further clean up builder crate (#161)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants