Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter Empty Updates from YDoc.observe_after_transaction #104

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Waidhoferj
Copy link
Collaborator

Fixes #98

observe_after_transaction callbacks should only trigger if there are contentful updates to the CRDT. There are certain operations that need a YTransaction to complete, but don't mutate any underlying state. This caused empty updates in observe_after_transaction, which is a meaningless event.

To avoid propagating these noops, @davidbrochart and I added this boilerplate to our callbacks:

def send_updates(self, txn_event: Y.AfterTransactionEvent):
        update = txn_event.get_update()
        if update != b'\x00\x00':
            send_update(update) 

Since we expect this behavior across the board, this PR filters out empty updates before the callback is triggered, so we will no longer have to add this check on a per-case basis.

@Waidhoferj Waidhoferj linked an issue Dec 20, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty updates to_json() generates updates
1 participant