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

父子应用都是angular17,子引用在使用MutationObserver api会报错堆栈溢出 #1535

Open
tmx-502 opened this issue Feb 26, 2025 · 7 comments
Assignees
Labels
Working on it Working on this issue

Comments

@tmx-502
Copy link

tmx-502 commented Feb 26, 2025

问题描述

父子应用都是angular17,子引用在使用MutationObserver api会报错堆栈溢出。当前仅按照官网配置了基础的框架。

复现步骤

  1. 基础父子应用代码
  2. new MutationObserver()

上传截图

Image

Image

复现仓库

请提供一个精简的代码仓库,然后上传到自己的 github,以帮助我们复现您的问题。

环境信息

  • micro-app版本:1.0.0-rc.21
  • 主应用前端框架&版本:angular 17.3.11
  • 子应用前端框架&版本:angular 17.3.11
  • 构建工具&版本:angular CLI
@tmx-502
Copy link
Author

tmx-502 commented Feb 26, 2025

最新调试 父子应用共用了zone.js后 不报错了 但是MutationObserver失效,部分UI框架功能也失效了

@sea-chao sea-chao added Working on it Working on this issue Need Reproduction 需要复现步骤 and removed Working on it Working on this issue labels Feb 28, 2025
Copy link

Hello @tmx-502. In order to facilitate location and troubleshooting, we need you to provide a realistic GitHub repository.
您好 @tmx-502, 为了方便定位和排查问题,我们需要您提供一个重现实例,请提供一个尽可能精简的 GitHub 仓库地址。

@tmx-502
Copy link
Author

tmx-502 commented Mar 3, 2025

抱歉公司网络无法上传代码到git。以上版本均是angular最小实现案例

@tmx-502
Copy link
Author

tmx-502 commented Mar 6, 2025

疑似源码中 src\sandbox\iframe\window.ts patchWindowProperty对MutationObserver进行了修改 (escape2RawWindowRegExpKeys中存在MutationObserver)

function patchWindowProperty (
appName: string,
microAppWindow: microAppWindowType,
sandbox: IframeSandbox,
):void {
const rawWindow = globalEnv.rawWindow

escape2RawWindowKeys.forEach((key: string) => {
microAppWindow[key] = bindFunctionToRawTarget(rawWindow[key], rawWindow)
})

Object.getOwnPropertyNames(microAppWindow)
.filter((key: string) => {
escape2RawWindowRegExpKeys.some((reg: RegExp) => {
if (reg.test(key) && key in microAppWindow.parent) {
if (isFunction(rawWindow[key])) {
microAppWindow[key] = bindFunctionToRawTarget(rawWindow[key], rawWindow)
} else {
const { configurable, enumerable } = Object.getOwnPropertyDescriptor(microAppWindow, key) || {
configurable: true,
enumerable: true,
}
if (configurable) {
rawDefineProperty(microAppWindow, key, {
configurable,
enumerable,
get: () => rawWindow[key],
set: (value) => { rawWindow[key] = value },
})
}
}
return true
}
return false
})

导致了 MutationObserver函数在zone.js中执行出现了问题
正常环境下:MutationObserver
Image

子应用环境:MutationObserver

Image

@tmx-502
Copy link
Author

tmx-502 commented Mar 7, 2025

最小复现仓库 https://github.com/tmx-502/micro-app-angular-demo/tree/master

Copy link

Since the issue was labeled with Need Reproduction, but no response in 7 days. This issue will be close. If you have any questions, you can comment and reply.
由于该 issue 被标记为需要可复现步骤,却 7 天未收到回应。现关闭 issue,若有任何问题,可评论回复。

@tmx-502
Copy link
Author

tmx-502 commented Mar 15, 2025

@sea-chao 问题被关闭了 麻烦重开一下 仓库已上传

@timhub66 timhub66 added Working on it Working on this issue and removed Need Reproduction 需要复现步骤 labels Mar 18, 2025
@timhub66 timhub66 reopened this Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working on it Working on this issue
Projects
None yet
Development

No branches or pull requests

3 participants