Skip to content

when use zone.js & ant design, the page will Endless loop #41506

Closed

Description

@nuonuoge

🐞 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
ant-design/ant-design#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?

Activity

  1. added this to the needsTriage milestone on Apr 8, 2021
  2. added
    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
    on Apr 9, 2021
  3. modified the milestones: needsTriage, Backlog on Apr 9, 2021
  4. nuonuoge commented on Apr 16, 2021

    @nuonuoge
    Author

    use with rc-trigger v4.5.0,when import zone.js the setstate never refresh value, endless loop,if use settimout instead promise.resolve() will slove, But I don't know this is caused by zone.js Or trigger
    image

  5. self-assigned this
    on Apr 22, 2021
  6. JiaLiPassion commented on Apr 22, 2021

    @JiaLiPassion
    Contributor

    @nuonuoge , I can not reproduce (click the popover and the click button`, popup menu is displayed correctly), could you give more details steps to reproduce the issue?

  7. nuonuoge commented on Apr 22, 2021

    @nuonuoge
    Author

    @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

  8. JiaLiPassion commented on May 4, 2021

    @JiaLiPassion
    Contributor

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

  9. nuonuoge commented on May 10, 2021

    @nuonuoge
    Author

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

  10. Archao-ME commented on May 17, 2021

    @Archao-ME

    I have the same issues too.

  11. imcuttle commented on May 18, 2021

    @imcuttle

    has the same issues too +1

  12. sunny15100 commented on May 20, 2021

    @sunny15100

    the same issues when use micro-frontends

  13. imcuttle commented on May 25, 2021

    @imcuttle

    I guess the issue is because of single-spa's side effect.
    single-spa/single-spa-angular#113

  14. 3 remaining items

  15. olivewind commented on Oct 21, 2021

    @olivewind

    @kbakba thanks,it works for me

  16. xiaody commented on Dec 6, 2021

    @xiaody

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

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

  17. xiaody commented on Dec 11, 2021

    @xiaody

    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 #44446. But the latest antd(4.17.3) seems compatible as I tried.

  18. JiaLiPassion commented on Mar 5, 2022

    @JiaLiPassion
    Contributor

    Sorry for the late reply, I created a PR to fix this one.

  19. Sherry-Lee commented on May 23, 2022

    @Sherry-Lee

    Is this issue solved? I'm using the angular 11 and ant, still facing the same problem :(

  20. yanhaijing commented on Nov 5, 2022

    @yanhaijing

    react-component/trigger@017131d?diff=split
    新的rc-trigger改成了useLayoutEffect 实现,测试已经不存在这个问题了

  21. au-z commented on Dec 1, 2022

    @au-z

    @nuonuoge - wondering if you were able to resolve the issue? I am seeing the same in my own micro-front-end app.

  22. yanhaijing commented on Dec 2, 2022

    @yanhaijing

    @nuonuoge - wondering if you were able to resolve the issue? I am seeing the same in my own micro-front-end app.

    Two ways to solve the problem:

    1. to upgrade antd

    react-component/trigger@017131d?diff=split 新的rc-trigger改成了useLayoutEffect 实现,测试已经不存在这个问题了

    1. Fix node_modules rc-trigger by self, you can apply it via yarn patch or patch-package

    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

  23. angular-automatic-lock-bot commented on Jan 2, 2023

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  24. locked and limited conversation to collaborators on Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: zonesIssues related to zone.jsstate: has PR

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions