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

Is it possible to use transaction with web worker? #490

Open
quolpr opened this issue Oct 21, 2021 · 0 comments
Open

Is it possible to use transaction with web worker? #490

quolpr opened this issue Oct 21, 2021 · 0 comments

Comments

@quolpr
Copy link

quolpr commented Oct 21, 2021

I am just curious, will the transaction work as expected if I do this:

    worker.postMessage({
      id: 2,
      action: "exec",
      sql: "BEGIN TRANSACTION"
    });

    worker.postMessage({
      id: 3,
      action: "exec",
      sql: "INSERT ...",
      params: { "$id": 1 }
    });

    worker.postMessage({
      id: 4,
      action: "exec",
      sql: "INSERT ...",
      params: { "$id": 2 }
    });


    worker.postMessage({
      id: 5,
      action: "exec",
      sql: "COMMIT"
    });

How can I be sure, that only id 3, 4 will be committed in the current transaction? I mean, after the transaction started I can't guarantee that other async codes could be executed that could not relate to the current transaction(for example, when setTimeout happens). Is there something like the ID of the transaction, under which other queries should be executed?

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

No branches or pull requests

1 participant