Skip to content
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

Fix back navigation after POST form submission #1014

Merged
merged 1 commit into from
Sep 28, 2023
Merged

Commits on Sep 27, 2023

  1. Fix back navigation after POST form submission

    This commit fixes a bug where navigating back after submitting a POST
    form would not show the previous page. The bug was introduced in
    #949. The new cache API is async
    since it needs to access CacheStorage which is async. In that PR,
    getCachedSnapshot was changed to be async, but hasCachedSnapshot was not
    changed. This meant that getCachedSnapshot would always return a promise,
    which is truthy, and so hasCachedSnapshot which just checked that the
    return value was not null would always return true.
    
    The bug would show up when you tried to navigate back to a page after
    a post form submission. The form submission would clear the cache, but the
    restoration visit would think it had a cached snapshot and so would not
    issue a request. This meant that the page would not be restored and nothing
    would happen.
    
    There's a new test in navigation_tests.js that reproduces this bug.
    
    The fix is to make hasCachedSnapshot async and await it in the places
    where it is used.
    afcapel committed Sep 27, 2023
    Configuration menu
    Copy the full SHA
    4b292d4 View commit details
    Browse the repository at this point in the history