Clean up IndexedDB previous-page listener - #55
Closed
issackjohn wants to merge 1 commit into
Closed
Conversation
There was a problem hiding this comment.
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-loadedlistener +iterationFinishedListener.promiseResolvestate withwaitForPreviousPageLoaded()that usesaddEventListener(..., { once: true }). - Register the listener immediately before clicking the previous-page button, then
awaitthe resulting promise. - Apply the same update to both the source and generated
distworkload 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.
The DeletingAllItems step stored its resolver as a property on the iterationFinishedListener function object, and registered a previous-page-loaded listener that was never removed. Replace it with a waitForPreviousPageLoaded() helper that registers a one-shot listener per page transition, so the resolver is scoped to the navigation it belongs to and the listener removes itself once the event fires.
issackjohn
force-pushed
the
fix-indexeddb-page-listener
branch
from
July 24, 2026 23:40
4ad12d3 to
d31cc45
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Rework how the
DeletingAllItemsstep waits for the IndexedDB TodoMVC app to finish aprevious-page navigation.
Problem
The step kept its promise resolver as a property hung off the
iterationFinishedListenerfunction object, and registered a
previous-page-loadedlistener that was never removed:resolved depended on loop ordering rather than being explicit.
removeEventListener.never navigates and never awaits it.
Change
Add a module-scope
waitForPreviousPageLoaded()helper that returns a promise backed by a{ once: true }listener, and call it immediately before clicking the Previous button.Each page transition now owns its own listener and resolver, and the listener removes itself
once the event fires.
previous-page-loadedis dispatched only fromtodo-app'smoveToPreviousPage(), whichruns only in response to the bottombar's
previous-pageevent from that button click. Soregistering the listener just before the click cannot miss the event or observe a stray one.
This is a refactor of the benchmark's synchronization only. The measured work is unchanged.
Notes
dist/src/workload-test.mjsis regenerated fromsrc/workload-test.mjsbynpm run buildinsuites-experimental/javascript-wc-indexeddb; both are updated here sothe checked-in build stays in sync.
Validation
npm run test:node— 66 passing, including theresources.txtvalidity checkeslintandprettier --checkclean on the changed source