Skip to content

Warning during commit or rollback of the transaction - "No transaction is active" #164

Closed

Description

@maksym-kyryliuk

Describe the bug
After updating to the 9.2.2, every time I manually commit or roll back the transaction I am getting a warning:

image

  • op-sqlite version: 9.2.2
  • RN version: 0.73.4

To reproduce the issue is enough to use code from documentation:

await db.transaction((tx) => {
  const { status } = await tx.execute(
    'UPDATE sometable SET somecolumn = ? where somekey = ?',
    [0, 1]
  );

  await tx.rollback();
});
await db.transaction((tx) => {
  const { status } = await tx.execute(
    'UPDATE sometable SET somecolumn = ? where somekey = ?',
    [0, 1]
  );

  await tx.commit();
});
await db.transaction(async tx => {
  try {
    const {status} = await tx.execute(
      "UPDATE sometable SET somecolumn = ? where somekey = ?",
    [0, 1]
  );

    throw new Error('Random Error!');
  } catch (error) {
    tx.rollback();
  }
});

My configuration:

  "op-sqlite": {
    "sqlcipher": false,
    "crsqlite": false,
    "performanceMode": "2",
    "sqliteFlags": "-DSQLITE_DQS=1",
    "libsql": false,
    "iosSqlite": false,
    "fts5": true
  }

Activity

  1. ospfranco commented on Oct 15, 2024

    @ospfranco
    Contributor

    Can you create a reproducible example? All the tests are passing

  2. maksym-kyryliuk commented on Oct 15, 2024

    @maksym-kyryliuk
    Author

    @ospfranco Sure, here is the link to the example.

    Load the app, and press the "Go to list" button. On the next screen, you will see 2 buttons:

    1. Add category with records - will start a transaction and call tx.commit() in the end
    2. Test error - will start a transaction, throw an error, and in the catch will call tx.rollback().

    Both of them leads to the warning below:
    image

  3. maksym-kyryliuk commented on Oct 15, 2024

    @maksym-kyryliuk
    Author

    Despite the warning above, the logic seems to work correctly for both commit and rollback. But this warning appears every time now for these cases.

    Upd: Updated the title and description of the issue to reflect it.

  4. changed the title [-]Not possilbe to commit or rollback transaction - "No transaction is active"[/-] [+]Warning during commit or rollback of the transaction - "No transaction is active"[/+] on Oct 15, 2024
  5. maksym-kyryliuk commented on Oct 15, 2024

    @maksym-kyryliuk
    Author

    Also there are two logs seems wasn't removed from the release:

     LOG  BEFORE FLUSH
     LOG  AFER FLUSH
    

    Link: https://github.com/OP-Engineering/op-sqlite/blob/main/src/index.ts#L352

  6. ospfranco commented on Oct 16, 2024

    @ospfranco
    Contributor

    You have to await the commit or the rollback. All sql operations are now async. After changing no warning is shown.

    OSP 000431

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions