angular: when use zone.js & ant design, the page will Endless loop

šŸž bug report

Affected Package

The issue is caused by package @angular/zone.js

Is this a regression?

0.11

Description

when use select tooltip popover, th page will in Endless loop https://github.com/ant-design/ant-design/issues/28537 image

šŸ”¬ Minimal Reproduction

https://codesandbox.io/s/sanchonghongfafangshi-antd494-forked-92z1j?file=/index.js

šŸ”„ Exception or Error





šŸŒ Your Environment

angular: 11 ant-desing>= 4.7

Anything else relevant?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 7
  • Comments: 21 (3 by maintainers)

Commits related to this issue

Most upvoted comments

@JiaLiPassion when use micro-frontends(angular&vue&react), itā€™s a big side effects, hope can be resolved quickly

@nuonuoge , I can reproduce now, it is an edge case, I will try to figure out how to make a workable solutionā€¦

Temporary solution:

patch for rc-trigger:

diff --git a/node_modules/rc-trigger/es/Popup/PopupInner.js b/node_modules/rc-trigger/es/Popup/PopupInner.js
index 66e4ac8..837e69d 100644
--- a/node_modules/rc-trigger/es/Popup/PopupInner.js
+++ b/node_modules/rc-trigger/es/Popup/PopupInner.js
@@ -78,9 +78,9 @@ var PopupInner = /*#__PURE__*/React.forwardRef(function (props, ref) {
       setAlignedClassName(nextAlignedClassName); // Repeat until not more align needed

       if (alignedClassName !== nextAlignedClassName) {
-        Promise.resolve().then(function () {
+        setTimeout(function () {
           forceAlign();
-        });
+        }, 0);
       } else {
         goNextStatus(function () {
           var _prepareResolveRef$cu;
diff --git a/node_modules/rc-trigger/lib/Popup/PopupInner.js b/node_modules/rc-trigger/lib/Popup/PopupInner.js
index 0fc3e2f..cc7149b 100644
--- a/node_modules/rc-trigger/lib/Popup/PopupInner.js
+++ b/node_modules/rc-trigger/lib/Popup/PopupInner.js
@@ -98,9 +98,9 @@ var PopupInner = /*#__PURE__*/React.forwardRef(function (props, ref) {
       setAlignedClassName(nextAlignedClassName); // Repeat until not more align needed

       if (alignedClassName !== nextAlignedClassName) {
-        Promise.resolve().then(function () {
+        setTimeout(function () {
           forceAlign();
-        });
+        }, 0);
       } else {
         goNextStatus(function () {
           var _prepareResolveRef$cu;

You can apply it via yarn patch or patch-package

After quite some debugging, I made a pure JS reproduction without any React thing https://stackblitz.com/edit/angular-41506 . This reproduction kinda simulates Reactā€™s scheduler and invoke guard, and obviously zone-patch-message-port fixes the issue.

For the two React reproductions above in this thread, adding import 'zone.js/plugins/zone-patch-message-port'; BEFORE import ... from 'react-dom' also does the fix.

@JiaLiPassion https://stackblitz.com/edit/react-mfqbxp you can use this repo, sometimes itā€™s work, you can reopen it times, when click this page will endless loop delete zone.jsļ¼Œitā€™s work

ā€“> https://stackblitz.com/edit/react-hisbdi?file=src%2Findex.js fixed

I managed to create a reproduction without ant design, but havnā€™t figured out why this happens.

https://stackblitz.com/edit/react-ylox6f

ā€“> https://stackblitz.com/edit/react-zyezvq?file=src%2Findex.js fixed

Unfortunately for old versionā€™s antd Select, zone-patch-message-port is not enough. There seems some other issues about ResizeObserver or maybe https://github.com/angular/angular/issues/44446. But the latest antd(4.17.3) seems compatible as I tried.

the same issues when use micro-frontends

has the same issues too +1

@JiaLiPassion https://stackblitz.com/edit/react-mfqbxp you can use this repo, sometimes itā€™s work, you can reopen it times, when click this page will endless loop delete zone.jsļ¼Œitā€™s work

@kbakba thanksļ¼Œit works for me