Troubleshooting & FAQ
Common issues and solutions when working with Vuer-RTC.
Messages Not Syncing
Problem: Operations are committed but not appearing on other clients.
Common causes:
WebSocket Connection Issues
- Check connection status:
- Verify server is receiving messages:
- Test with the echo server:
The echo server logs all messages to console. Use it to verify your client is sending properly formatted messages.
Missing Acknowledgements
Messages need to be acknowledged for compaction and snapshot creation.
Solution: Ensure server echoes messages back to all clients:
Verify acknowledgements:
Messages remain unacknowledged until the server echoes them back. Without acks, snapshots cannot advance and the journal will grow indefinitely.
Text CRDT Producing Wrong Results
Problem: Collaborative text editing produces unexpected or corrupted output.
Root cause: Causal ordering violations.
Understanding the Issue
The Rope CRDT requires operations to be applied in causal order:
Client B's operation has clock: { A: 1, B: 1 }, meaning it depends on A's operation (A: 1).
Solution: Buffer Out-of-Order Messages
If you see text appearing in the wrong positions or deletions affecting the wrong characters, check message ordering. The vector clock in each message tracks dependencies.
Quick Test
Undo Not Working
Problem: store.undo() returns null or has no effect.
Common causes:
1. No Committed Messages to Undo
Only committed messages can be undone. Operations in the edit buffer are not yet in the journal.
2. Target Message Already Compacted
When a snapshot is created, older journal entries are compacted:
Solution: Adjust compaction threshold:
Higher compaction thresholds mean more memory usage. Balance undo history depth with memory constraints.
3. Message from Different Session
undo() only undoes messages from the current session:
To undo a specific message:
Performance Degrading Over Time
Problem: Application becomes slower after extended use.
Root cause: Journal grows too large without compaction.
Diagnosis
If the journal has hundreds or thousands of entries, you need more frequent compaction.
Solution 1: Adjust Compaction Threshold
Solution 2: Manual Compaction
Solution 3: Periodic Cleanup
Compaction bakes acknowledged journal entries into the snapshot and removes them from the journal. This keeps replay fast.
Type Errors in TypeScript
Problem: Import errors or missing types.
Incorrect Import Path
Available Subpath Exports
Check package.json exports field for the complete list of available subpath exports.
Missing Type Definitions
If types are not resolving:
Check your tsconfig.json:
State Divergence Between Clients
Problem: Clients show different states after the same operations.
Root cause: Clock synchronization issues or non-deterministic conflict resolution.
Verify Message Order
All clients must apply messages in the same causal order:
Compare logs across clients - the journal order should be identical.
Check Last-Write-Wins Ordering
For *.set operations, lamportTime determines the winner:
Solution: Ensure lamport time increments correctly:
If lamport times are not monotonically increasing, conflict resolution will be inconsistent. Verify the server is not modifying lamport times.
Debugging Tool: State Hash
Create a deterministic hash of state for comparison:
All clients should show the same hash after convergence.
Memory Leaks
Problem: Memory usage grows unbounded over time.
Root cause: Journal not being compacted.
Diagnosis
Common Causes
- Messages never acknowledged:
Solution: Ensure server echoes messages back.
- Compaction disabled or threshold too high:
- Edits never committed:
Uncommitted edits stay in memory indefinitely. Make sure to call commit() after editing operations, especially in event handlers like onMouseUp or onDragEnd.
WebSocket Disconnections
Problem: Connection drops and messages are lost.
Implement Retry Logic
Reconnection with Message Replay
Keep a buffer of sent messages for replay:
The retry utilities in @vuer-ai/vuer-rtc/networking provide exponential backoff and jitter to avoid thundering herd problems.
Heartbeat to Detect Disconnections
Still Having Issues?
Open an issue on GitHub with:
- Minimal reproduction
- Client and server code
- Console logs showing the issue
- Expected vs actual behavior