Skip to content

fix(webui): memoize MainContext value in Main - #2348

Merged
gnugomez merged 1 commit into
eclipse-openvsx:mainfrom
trivikr:webui-memoize-handleError
Oct 20, 2026
Merged

gnugomez merged 1 commit into
eclipse-openvsx:mainfrom
trivikr:webui-memoize-handleError

Conversation

@trivikr

@trivikr trivikr commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Main rebuilt the MainContext value and its handleError and updateUser callbacks on every render. This re-rendered all context consumers and re-ran effects that depend on those callbacks.

Wrap handleError and updateUser in useCallback and the context value in useMemo.

Main rebuilt the MainContext value and its handleError and updateUser
callbacks on every render. Every context consumer re-rendered each time,
and effects that depend on those callbacks re-ran.

Wrap handleError and updateUser in useCallback and the context value in
useMemo, so their identity only changes when the underlying state or
props do.

Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
@trivikr
trivikr force-pushed the webui-memoize-handleError branch from e567791 to 7976adf Compare October 19, 2026 04:40
@netomi
netomi requested a review from gnugomez October 19, 2026 08:35

@gnugomez gnugomez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point we need to consider moving this main context to something like zustand to better manage re-renders, for now this is a good improvement :)

This context has gotten too big, and any update to the context will trigger a re-render, is not that critical since it's not a context that updates very often tho.

@gnugomez
gnugomez merged commit 15d4d82 into eclipse-openvsx:main Oct 20, 2026
5 checks passed
@trivikr
trivikr deleted the webui-memoize-handleError branch October 20, 2026 13:53
netomi added a commit that referenced this pull request Oct 21, 2026
Render the real Main with a page whose query keeps failing through
useReportedQuery, and check the dialog is reported once, closes, and
stays closed. The existing tests stub a stable handleError, so they
could not catch the report loop fixed in #2348; this test fails
against the pre-#2348 Main.

Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
Co-authored-by: Thomas Neidhart <thomas.neidhart@gmail.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
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