fix: crash in checkMessageQueue due to sessionId/index key mismatch#215
Open
dionisos2 wants to merge 2 commits into
Open
fix: crash in checkMessageQueue due to sessionId/index key mismatch#215dionisos2 wants to merge 2 commits into
dionisos2 wants to merge 2 commits into
Conversation
In 1.7.7, sendMessage switched to keying messageData.ack by connection.sessionId (string) instead of connection.index (number), but checkMessageQueue and _sendMessage still used item.socket.index (numeric), causing a TypeError on undefined when trying to resend unacked messages after 500ms. This crashed the WebSocket connection. Three fixes: - checkMessageQueue: use item.sessionId instead of item.socket.index, with null guard - _sendMessage: add null guard on messageData.ack[index] before access - handleAck (server): use data.sessionId as source_connection fallback so browser acks are properly matched to their queue entry Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
|
Sorry, I thought it worked correctly but there is a problem with the last version of tiddlywiki, I will try to fix it. |
Widget.prototype.addEventListener silently ignores {once:true}, causing
handle-ack/loaded-tiddler/skinny-tiddlers listeners to accumulate across
saves. Replaced all 8 occurrences with explicit named-listener +
removeEventListener pattern so each listener self-removes on first call.
Also fix SendToBrowsers in ServerSide.js to compare connection.sessionId
instead of connection index against excludeConnection, preventing the
originating browser from receiving its own save echoed back.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
|
This seems to work now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Titre :
fix: crash in checkMessageQueue due to sessionId/index key mismatch (1.7.7)
Description :
Bug
In 1.7.7,
sendMessagewas updated to keymessageData.ackbyconnection.sessionId(a string like "planning123456") instead ofconnection.index(a number). However,checkMessageQueueand_sendMessagestill useditem.socket.index(numeric), causing aTypeError: Cannot read property 'received' of undefinedafter 500mswhenever the server had unacknowledged messages in the queue.
This crashed the active WebSocket connections, which manifested as the
sync button turning red when typing quickly in a text field.
Fixes (SharedFunctions.js)
checkMessageQueue: replaceitem.socket.indexwithitem.sessionIdand add a null guard
_sendMessage: add null guard onmessageData.ack[index]before accesshandleAck(server side): usedata.sessionIdassource_connectionfallback so browser acks are properly matched to their queue entry
How it was found
The bug was reproduced and diagnosed using Claude Code.