Skip to content

fix(blocks): queue render calls to avoid concurrent re-rendering - #3065

Open
Anurag-S1ngh wants to merge 1 commit into
codex-team:nextfrom
Anurag-S1ngh:fix/2745-concurrent-render
Open

Anurag-S1ngh wants to merge 1 commit into
codex-team:nextfrom
Anurag-S1ngh:fix/2745-concurrent-render

Conversation

@Anurag-S1ngh

Copy link
Copy Markdown
Contributor

Summary

Closes #2745.

Calling blocks.render() twice before the first call finished made the two operations interleave. The BlockManager.clear() of the second call ran while the first call was still removing blocks, which threw Can't find a Block to remove as an unhandled rejection and could leave duplicate blocks. This is the same failure path as #2439.

Changes

  • Queue render operations per editor instance in BlocksAPI
  • render() and renderFromHTML() now run one at a time, and the last call wins
  • A failed render does not block the queued operations
  • Invalid render() input still throws synchronously

Testing

  • New test in test/cypress/tests/api/blocks.cy.ts renders twice back to back and expects only the second payload
  • Without the fix the test fails with Can't find a Block to remove
  • yarn lint
  • npx cypress run --spec test/cypress/tests/api/blocks.cy.ts
  • npx cypress run --spec test/cypress/tests/onchange.cy.ts
  • npx cypress run --spec test/cypress/tests/readOnly.cy.ts
  • npx cypress run --spec test/cypress/tests/copy-paste.cy.ts

All specs pass, lint reports 0 errors.

This branch has not been deployed

No deployments
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.

Inline toolbar usage and render data

1 participant