-
Notifications
You must be signed in to change notification settings - Fork 27
appHistory.transition.finished/navigatesuccess/navigateerror can be fired before finished promise #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I've written some WIP tests and this isn't really observable in the way I thought it was. Because events happen immediately and promise handlers are always microtask-delayed, you would expect that resolveFinishedPromise();
fireNavigateSuccessEvent(); then the following JavaScript code appHistory.addEventListener("navigatesuccess", () => console.log("navigatesuccess"));
appHistory.back().finished.then(() => console.log("finished promise")); will still log It all still seems very fragile... investigating... |
When writing an implementation I hadn't come across this specific requirement, and instead had Implemented somewhat like:
In node + deno I found that if the promise provided to |
|
I've found a couple of fixes we'll need to make in the spec in this area; see here for the corresponding Chromium changes which will soon be transferred over. |
Specifically: * Mark finished promises as handled. * Change when currentchange fires slightly, so that currentchange handlers can't cause microtasks to run at an unusual time and thus swap the usual ordering of events and promises. This also allows us to clean up the "did finish before commit" bit since, contrary to the note in the spec, it was actually only necessary because of the currentchange-triggers-microtasks problem. * Always "wait for all" on at least one promise, since the zero-promise special case causes timing changes. Closes #199. This corresponds to the Chromium change in https://chromium-review.googlesource.com/c/chromium/src/+/3413934.
Specifically: * Mark finished promises as handled. * Change when currentchange fires slightly, so that currentchange handlers can't cause microtasks to run at an unusual time and thus swap the usual ordering of events and promises. This also allows us to clean up the "did finish before commit" bit since, contrary to the note in the spec, it was actually only necessary because of the currentchange-triggers-microtasks problem. * Always "wait for all" on at least one promise, since the zero-promise special case causes timing changes. Closes #199. This corresponds to the Chromium change in https://chromium-review.googlesource.com/c/chromium/src/+/3405377.
Specifically: * Mark finished promises as handled. * Change when currentchange fires slightly, so that currentchange handlers can't cause microtasks to run at an unusual time and thus swap the usual ordering of events and promises. This also allows us to clean up the "did finish before commit" bit since, contrary to the note in the spec, it was actually only necessary because of the currentchange-triggers-microtasks problem. * Always "wait for all" on at least one promise, since the zero-promise special case causes timing changes. Closes #199. This corresponds to the Chromium change in https://chromium-review.googlesource.com/c/chromium/src/+/3405377.
In traversal cases, it's possible for the promise passed to
transitionWhile()
to settle within a single microtask, while it takes a task to actually perform the traversal.We've accounted for this partially, in the case of the promise returned by
appHistory.back().finished
, by using the did finish before commit technique to delay thefinished
promise until after the commit happens (and thecommitted
promise fulfills.But I believe we are not doing anything to prevent early firing of
navigatesuccess
/navigaterror
, or early resolution ofappHistory.transition.finished
.This will similarly impact #197, i.e. we should not do focus reset or scroll restoration too early in these cases.
We need to generalize the mechanism for delaying finish (in all its forms) until after commit.
The text was updated successfully, but these errors were encountered: