umijs / qiankun

📦 🚀 Blazing fast, simple and complete solution for micro frontends.
https://qiankun.umijs.org
MIT License
15.86k stars 2.02k forks source link

[Bug]当router.beforeEach使用了async时,浏览器后退时会出现Target container with #view-main not existed while app1 mounting! #3023

Open benBenXuChao opened 2 weeks ago

benBenXuChao commented 2 weeks ago

浏览器回退时报错:Uncaught Error: application 'app1' died in status SKIP_BECAUSE_BROKEN: [qiankun]: Target container with #view-main not existed while app1 mounting!

  1. 主应用路由使用beforeEach,并且使用了async

router.beforeEach(async (to, from, next) => { await new Promise(resolve => { setTimeout(() => { resolve() }, 300); }) next() })

最小可复现仓库

https://github.com/EasonMar/qiankun-issue-demo.git

需要对代码进行一个小改动 改动文件路径:packages/main/src/router/index.js 将给router添加一个beforeEach

router.beforeEach(async (to, from, next) => { await new Promise(resolve => { setTimeout(() => { resolve() }, 300); }) next() }) export default router

复现步骤,错误日志以及相关配置

点击子应用路由后,点击浏览器的前进后退按钮

相关环境信息

"vue": "3.2.31", "qiankun": "2.7.0",