Skip to content

[BUG]: Split page error is thrown when rapidly and repeatedly splitting pages #885

@cburwell

Description

@cburwell

Report hasn't been filed before

  • I have verified that the bug I'm about to report hasn't been filed before

What version of OpenMarch are you using?

0.0.22

Operating system

Linux (x64)

Describe the bug

What went wrong?

Clicking "Split page" in the Page Inspector multiple times in rapid succession results in a inspector.page.split.error error and the page does not split.

What did you expect to happen?

Clicking the "Split page" button should split a page and disable the button until the operation is complete.

What steps could we take to reproduce the issue?

  1. Create a new page.
  2. Select the new page.
  3. Click "Split page" multiple times in rapid succession (a quick double or triple tap seems to work).
  4. See toast error for inspector.page.split.error and page is not split.

Dev notes

Reproducing this results in the following libsql error:

Error from SQL proxy: SqliteError: cannot start a transaction within a transaction
     at convertError (OpenMarch/node_modules/.pnpm/libsql@0.5.22/node_modules/libsql/index.js:59:12)
     at Statement.run (OpenMarch/node_modules/.pnpm/libsql@0.5.22/node_modules/libsql/index.js:335:13)
     at handleSqlProxyWithDb (OpenMarch/apps/desktop/dist-electron/main/index.js:5327:23)
     at handleSqlProxy (OpenMarch/apps/desktop/dist-electron/main/index.js:5368:18)
     at Session.<anonymous> (node:electron/js2c/browser_init:2:110648)
     at Session.emit (node:events:508:28) {
   code: 'SQLITE_ERROR',
   rawCode: 1
 }

This is because each click of the "Split page" button fires a split mutation (which contains a Sqlite BEGIN command). Sqlite cannot support nested transactions, so a second mutation fired before the first one returns inserts a second BEGIN in the middle of the transaction, causing the error.

Suggested fix

The splitPage() function in apps/desktop/src/components/inspector/PageEditor.tsx should be disabled until the previous split is completed.

Upload your .dots file (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions