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(vue-app): skip page render early on error or navigation #20719
Conversation
Β Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
@@ -995,5 +995,6 @@ async function mountApp (__app) { | |||
errorHandler(err) | |||
} | |||
}) | |||
}) | |||
}, | |||
{ aborted: false }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not put too much thought into that part of the code (the SPA case). I could look more if needed but it could be just left like that, without supporting early abort.
@manniL I see you've been assigned. Could you have a look at this? |
Looks like a good solution to me for covering basic use cases π |
π Linked issue
#20691
β Type of change
π Description
This change attempts to interrupt page "rendering" early if the route is navigated away from while middleware or asyncData is in progress. Additionally, also interrupts as early as possible when
error()
is called so that the error page is not shown after user has navigated to another page already.Fixed by creating a plain
renderState
object that has anaborted
property set tofalse
initially, and passing that object to the internalrender
function and then also down to function that executes middlewares. If a newrender
is triggered (through therouter.beforeEach
hook) while the original one is in progress, theaborted
property is set totrue
so that the originalrender
pass can abort as soon as possible (once currently executing async function is done).I realize that this is not 100% proof solution as the user could do many weird things that would affect the state of the app from the middlewares or the
asyncData
handlers, but I think this should cover most common cases.Added tests that verify that the error page is not shown after navigating away from the page when the page triggers
error()
call or throws an exception. Unfortunately those have to rely on arbitrary 2s delay but I haven't found a better way to test that.π Checklist