Skip to content

Under the micro-frontend qiankun framework, setting sandbox to false behaves abnormally. #3961

@callqh

Description

@callqh

Describe the bug

I set sandbox: false under the main application of micro frontends, and then I have two sub-applications. In application A, I create instances and load remotely at runtime. When I first open the page, it displays normally in application A, but after switching to application B, an error occurs. Refreshing the page will make it work normally again, but switching from B back to A will still result in an error: Error: Invalid hook call. Hooks can only be called inside of the body of a function component.

I suspect it's because some fields set on the window property after createInstance are not destroyed in time when switching applications, causing application B to use snapshots or caches from application A. So I would like to ask if there is a way to promptly clear some caches generated by the runtime when the sub-application is unmounted?

Reproduction

Used Package Manager

yarn

System Info

System:
    OS: macOS 15.5
    CPU: (10) arm64 Apple M2 Pro
    Memory: 170.91 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.20.1 - ~/.nvm/versions/node/v16.20.1/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v16.20.1/bin/yarn
    npm: 8.19.4 - ~/.nvm/versions/node/v16.20.1/bin/npm
    bun: 0.6.13 - ~/.bun/bin/bun
  Browsers:
    Safari: 18.5

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions