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

Support for native async/await? #715

Closed
elierotenberg opened this Issue Apr 3, 2017 · 5 comments

Comments

Projects
None yet
4 participants
@elierotenberg

elierotenberg commented Apr 3, 2017

Hello,

As said in a previous issue, I'm currently working on a zone.js wrapper for Node designed to provide isolation for HTTP request handlers.

I'm working in Node 7.8, which supports native async/await.
Unless I'm doing something wrong, zone.js doesn't seem to interop nicely with native async functions.

The following piece of code:

const zone = Zone.current.fork({
  name: 'test-zone',
});
zone.run(async () => {
  console.log(Zone.current.name);
  await Promise.resolve();
  console.log(Zone.current.name);
  done();
});

yields:

test-zone
<root>

when using native async/await.
If I transpile the same code using babel-transform-async-to-generator, this yields:

test-zone
test-zone

the latter being the wanted behavior.

Am I doing something wrong? Is native async/await supported by zone.js, and if not, are there plans to support it? (Is it even possible?)

Thanks,

@elierotenberg

This comment has been minimized.

Show comment
Hide comment
@elierotenberg

elierotenberg Apr 3, 2017

After further testing, even when transpiled with babel, the example doesn't work as expected, since after the zone await-s, the Zone appears to have no pending microTask or macroTask (as per hasTaskState).

Any idea how to circumvent this limitation?

elierotenberg commented Apr 3, 2017

After further testing, even when transpiled with babel, the example doesn't work as expected, since after the zone await-s, the Zone appears to have no pending microTask or macroTask (as per hasTaskState).

Any idea how to circumvent this limitation?

@JiaLiPassion

This comment has been minimized.

Show comment
Hide comment
@JiaLiPassion

JiaLiPassion Apr 16, 2017

Collaborator

@elierotenberg , this is a issue, the native async/await behavior break Zone.invoke, I will try to figure out why, thank you for posting the issue.

Collaborator

JiaLiPassion commented Apr 16, 2017

@elierotenberg , this is a issue, the native async/await behavior break Zone.invoke, I will try to figure out why, thank you for posting the issue.

@Eugeny

This comment has been minimized.

Show comment
Hide comment
@Eugeny

Eugeny Apr 17, 2017

Thanks. This basically breaks Angular with the Typescript's ES2017 target

Eugeny commented Apr 17, 2017

Thanks. This basically breaks Angular with the Typescript's ES2017 target

@JiaLiPassion

This comment has been minimized.

Show comment
Hide comment
@JiaLiPassion

JiaLiPassion Apr 18, 2017

Collaborator

@Eugeny , yes, I have post another issue #740, and I will post my research result there.

Collaborator

JiaLiPassion commented Apr 18, 2017

@Eugeny , yes, I have post another issue #740, and I will post my research result there.

@mhevery

This comment has been minimized.

Show comment
Hide comment
@mhevery

mhevery Apr 18, 2017

Member

Duplicate of #740. The short of it is that ES2017 target is not supported yet.

Member

mhevery commented Apr 18, 2017

Duplicate of #740. The short of it is that ES2017 target is not supported yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment