Show HN: Zones for Node.js using async_hooks
github.com
github.com
In case anyone else was wondering.
This is similar to dynamic scoping.
Does the fact that Minizone is based on "async_hooks" make it more future proof? Less hacky?
The OP is a project implementing a zone.js-style API using async_hooks. Also see this PR on the original zone.js project where they are working to use this in the original library, but have hit many edge cases/issues: https://github.com/angular/zone.js/pull/795
The drawback was the need to manually wrap all participating async functions into a special macro (zones/bound-fn). With async_hooks this could be automated I believe.
Obviously, you'd want to avoid coupling your code to an HTTP-specific context if you want to expose a gRPC endpoint in the future.
Are there any other downsides to this approach?
Also, they typically come with a sizable perf hit: https://github.com/bmeurer/async-hooks-performance-impact
Now all I need to do is to abstract domain usage so when the time cones I can switch to Zones.