fix: ensure post() completes before shareHistoricalKeys()#15
Merged
ThomasHalwax merged 1 commit intomainfrom Mar 24, 2026
Merged
fix: ensure post() completes before shareHistoricalKeys()#15ThomasHalwax merged 1 commit intomainfrom
ThomasHalwax merged 1 commit intomainfrom
Conversation
post() did not await __post(), so it returned immediately while chunks were still being enqueued in the background. When shareHistoricalKeys() was called right after, its callback was enqueued before the content chunks — and ran before any Megolm session existed, finding 0 keys to share. Additionally, schedule() now awaits enqueue() to guarantee that FIFO insertion order matches call order (persistent DB entries take longer to enqueue than in-memory callbacks). Changes: - project: post() now awaits __post() - project: __post() uses for..of instead of forEach to serialize chunk scheduling - project: shareHistoricalKeys() is now async, awaits schedule() - command-api: schedule() is now async, awaits enqueue()
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.
Problem
When sharing an E2EE layer,
shareHistoricalKeys()found 0 Megolm session keys to share — even though content had just been posted. This meant new members joining the layer had no keys and couldn't decrypt content until the safety-net mechanism fired (requiring the sharing member to be online).Root Cause
post()did notawaitits internal__post()call:So ODIN's share handler sequence:
The
shareHistoricalKeyscallback was enqueued in the command queue before the content chunks, ran first, and found no Megolm sessions yet.Fix
post()now awaits__post()__post()usesfor..ofinstead offorEachto serialize chunk schedulingshareHistoricalKeys()is now async, awaitsschedule()schedule()is now async, awaitsenqueue()to guarantee FIFO insertion orderTesting