Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

WIP(core): use asynchooks to resolve es2017 native async/await issue #984

Closed
wants to merge 1 commit into from

Conversation

JiaLiPassion
Copy link
Collaborator

@JiaLiPassion JiaLiPassion commented Dec 25, 2017

fix #740, #715

use async/hooks to resolve es2017 native async/await not in zone issue.
Because PromiseHook.kResolve will only fire when resolve is called, we don't know whether or not the promise is really resolved or not, so we still need the ZoneAwarePromise monkey-patch.

And I will remove other monkey-patch later to make an asynchooks based zone which is

  • promise use asynchooks + ZoneAwarePromise.
  • other async operations such as setTimeout/setInterval... will just use asynchooks.

now I made a basic test, when build in es2017, the code still in zone.

zone.run(async() => {
    print('run async', Zone.current.name);
    const outside = await asyncOutside();
    print('get outside', Zone.current.name);
    log.push(outside);

    async function asyncInside() {
      return 'asyncInside';
    } print('define inside', Zone.current.name);

    const inside = await asyncInside();
    print('get inside', Zone.current.name);
    log.push(inside);

    print('log', log.join(' '));
  });

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

angular with tsconfig target ES2017 async/await will not work with zone.js
2 participants