Files
next.orly.dev/TEST_NOW.md
mleku 581e0ec588
Some checks failed
Go / build (push) Has been cancelled
Go / release (push) Has been cancelled
Implement comprehensive WebSocket subscription stability fixes
- Resolved critical issues causing subscriptions to drop after 30-60 seconds due to unconsumed receiver channels.
- Introduced per-subscription consumer goroutines to ensure continuous event delivery and prevent channel overflow.
- Enhanced REQ parsing to handle both wrapped and unwrapped filter arrays, eliminating EOF errors.
- Updated publisher logic to correctly send events to receiver channels, ensuring proper event delivery to subscribers.
- Added extensive documentation and testing tools to verify subscription stability and performance.
- Bumped version to v0.26.2 to reflect these significant improvements.
2025-11-06 18:21:00 +00:00

2.8 KiB

Test Subscription Stability NOW

Quick Test (No Events Required)

This test verifies the subscription stays registered without needing to publish events:

# Terminal 1: Start relay
./orly

# Terminal 2: Run simple test
./subscription-test-simple -url ws://localhost:3334 -duration 120

Expected output:

✓ Connected
✓ Received EOSE - subscription is active

Subscription is active. Monitoring for 120 seconds...

[  10s/120s] Messages: 1 | Last message: 5s ago | Status: ACTIVE (recent message)
[  20s/120s] Messages: 1 | Last message: 15s ago | Status: IDLE (normal)
[  30s/120s] Messages: 1 | Last message: 25s ago | Status: IDLE (normal)
...
[120s/120s] Messages: 1 | Last message: 115s ago | Status: QUIET (possibly normal)

✓ TEST PASSED
Subscription remained active throughout test period.

Full Test (With Events)

For comprehensive testing with event delivery:

# Terminal 1: Start relay
./orly

# Terminal 2: Run test
./subscription-test -url ws://localhost:3334 -duration 60

# Terminal 3: Publish test events
# Use your preferred method to publish events to the relay
# The test will show events being received

What the Fixes Do

Before (Broken)

  • Subscriptions dropped after ~30-60 seconds
  • Receiver channels filled up (32 event buffer)
  • Publisher timed out trying to send
  • Events stopped being delivered

After (Fixed)

  • Subscriptions stay active indefinitely
  • Per-subscription consumer goroutines
  • Channels never fill up
  • All events delivered without timeouts

Troubleshooting

"Failed to connect"

# Check relay is running
ps aux | grep orly

# Check port
netstat -tlnp | grep 3334

"Did not receive EOSE"

# Enable debug logging
export ORLY_LOG_LEVEL=debug
./orly

Test panics

Already fixed! The latest version includes proper error handling.

Files Changed

Core fixes in these files:

  • app/listener.go - Subscription tracking + concurrent message processing
  • app/handle-req.go - Consumer goroutines (THE KEY FIX)
  • app/handle-close.go - Proper cleanup
  • app/handle-websocket.go - Cancel all on disconnect

Latest fix: Message processor now handles messages concurrently (prevents queue from filling up)

Build Status

All code builds successfully:

go build -o orly                               # Relay
go build -o subscription-test ./cmd/subscription-test  # Full test
go build -o subscription-test-simple ./cmd/subscription-test-simple  # Simple test

Quick Summary

Problem: Receiver channels created but never consumed → filled up → timeout → subscription dropped

Solution: Per-subscription consumer goroutines (khatru pattern) that continuously read from channels and forward events to clients

Result: Subscriptions now stable for unlimited duration