Commit 53c9b2f
committed
fix(stream-management): handle queue desync after page reload
When a page/app reloads, the outbound queue (outbound_q) is not persisted
but the server maintains its acknowledgment counter. On session resume:
1. Server sends <resumed h="N"/> with the real counter value
2. Client tries to remove N items from an empty queue
3. shift() returns undefined, causing a crash on item.stanza
This fix adds a guard that:
- Detects when queue is empty but server reports higher h value
- Resyncs the outbound counter to match server's value
- Breaks out of the loop to prevent the crash
Note: In-flight stanzas (sent but unacked at reload time) are still lost
since the queue is not persisted. A proper fix would require serializing
the queue to storage, which is beyond the scope of this patch.1 parent d9facdc commit 53c9b2f
1 file changed
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
94 | 108 | | |
95 | 109 | | |
96 | 110 | | |
| |||
0 commit comments