Skip to content

Conversation

stevensJourney
Copy link
Collaborator

Overview

This fixes an issue where table change notifications would sometimes report "garbage" changed table names.
For example see this snapshot of a batched notification:

{
    "tables": [
        "\n",
        "",
        "���������B\u0001",
        "ps_migration"
    ],
    "groupedUpdates": {},
    "rawUpdates": []
}

The table names are extracted from the heap via the pointer provided by SQLite. We convert the C pointer to a JavaScript string in the update notification handler.
SQLite3 executes the update hook synchronously. We execute our update notification callbacks in a setTimeout to avoid blocking SQLite3. This causes issues when using the provided pointer since the data could have been freed after SQLite's synchronous execution.

This changes the order of operations to first fetch the table name strings synchronously then fire the downstream callbacks asynchronously.

@stevensJourney stevensJourney marked this pull request as ready for review October 29, 2024 11:10
@stevensJourney stevensJourney merged commit 588937a into master Oct 29, 2024
1 check passed
@stevensJourney stevensJourney deleted the fix/memory-leak branch October 29, 2024 11:11
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.

2 participants