Skip to content

Clean up IndexedDB previous-page listener#55

Open
issackjohn wants to merge 1 commit into
responsive-designfrom
fix-indexeddb-page-listener
Open

Clean up IndexedDB previous-page listener#55
issackjohn wants to merge 1 commit into
responsive-designfrom
fix-indexeddb-page-listener

Conversation

@issackjohn

@issackjohn issackjohn commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace the resolver stored on iterationFinishedListener with a per-navigation promise.
  • Register a one-shot previous-page-loaded listener before clicking the Previous button, then await that page transition.
  • Keep the checked-in dist workload in sync with the source.

Why

The previous implementation kept mutable resolver state on a function object and registered a listener that was never removed. Scoping each listener to one page transition makes the control flow explicit and cleans it up automatically after the event fires.

Validation

  • git diff --check

Closes #52.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR cleans up the IndexedDB TodoMVC benchmark’s “previous page loaded” synchronization by replacing a shared, hidden promiseResolve function property with a per-transition one-shot promise tied to the previous-page-loaded event. This makes page-transition waiting deterministic (listener installed immediately before the click) and ensures the listener is automatically removed after firing.

Changes:

  • Replace the persistent previous-page-loaded listener + iterationFinishedListener.promiseResolve state with waitForPreviousPageLoaded() that uses addEventListener(..., { once: true }).
  • Register the listener immediately before clicking the previous-page button, then await the resulting promise.
  • Apply the same update to both the source and generated dist workload test files.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
experimental/javascript-wc-indexeddb/src/workload-test.mjs Switches “previous page loaded” waiting logic to a per-iteration one-shot promise to avoid missed events and hidden listener state.
experimental/javascript-wc-indexeddb/dist/src/workload-test.mjs Keeps generated dist workload test in sync with the updated source behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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