Skip to content

Render updates queued behind a render error - #5306

Closed
otarampinelli wants to merge 2 commits into
preactjs:mainfrom
otarampinelli:fix/rerender-queue-keep-pending
Closed

otarampinelli wants to merge 2 commits into
preactjs:mainfrom
otarampinelli:fix/rerender-queue-keep-pending

Conversation

@otarampinelli

@otarampinelli otarampinelli commented Oct 11, 2026 •

Copy link
Copy Markdown

Follow-up to #5305, as an alternative to its fix. Opened as a draft to discuss the behaviour change.

#5305 stops components queued behind a render error from freezing, by clearing COMPONENT_DIRTY on the components process() drops. They still lose the update they were queued for, though it only shows once something else re-renders them.

This keeps them queued instead and schedules another process(), so their pending updates render in the next flush:

} finally {
        if ((rerenderCount = rerenderQueue.length)) {
                (prevDebounce || queueMicrotask)(process);
        }
}
  • No error: the queue is already empty, so this just resets rerenderCount to 0, as before.
  • After an error: the remaining components keep their place and render on the next tick. A non-zero rerenderCount stops enqueueRender from scheduling a second flush in the meantime.
  • It always finishes: the component that threw had COMPONENT_DIRTY cleared before rendering, so it isn't queued again. Each failed flush removes at least one component.
  • It's also smaller than the loop in Clear dirty flag on components dropped after a render error #5305.

Behaviour change

An error no longer discards the rest of the batch. Components queued after the one that threw still render, one tick later. If the error left shared state inconsistent, they render with that state. They would also do so at their next update under #5305.

Testing

New test: should render updates that were queued behind a render that threw. It fails with #5305 fix and passes here:

pnpm exec vitest run test/browser/components.test.jsx -t "queued behind"
expected '<div><p>a</p><p>0</p></div>' to equal '<div><p>a</p><p>1</p></div>'

The tests from #5305 and the existing "should reset the rerender queue if rendering throws" still pass. Full suite: pnpm run test.

@github-actions

Copy link
Copy Markdown

📊 Tachometer Benchmark Results

Summary

A summary of the benchmark results will show here once they finish.

Results

The full results of your benchmarks will show here once they finish.

tachometer-reporter-action v2 for CI

@JoviDeCroock

Copy link
Copy Markdown
Member

https://github.com/preactjs/.github/blob/master/CODE_OF_CONDUCT.md#our-standards

LLM usage should be disclosed and other PR's are handling this issue

@otarampinelli
otarampinelli deleted the fix/rerender-queue-keep-pending branch October 11, 2026 15:08
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