Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Are domain.enter() and domain.exit() officially supported APIs? #5017

Closed
hueniverse opened this issue Mar 14, 2013 · 4 comments
Closed

Are domain.enter() and domain.exit() officially supported APIs? #5017

hueniverse opened this issue Mar 14, 2013 · 4 comments

Comments

@hueniverse
Copy link

They are very useful when domain.run() is too restrictive in what is actually running inside (e.g. callback outside the protected realm). Since they are not listed in the docs, I want to make sure.

@isaacs
Copy link

isaacs commented Mar 14, 2013

They're tricky to get right. If you enter a domain, you have to be sure you exit it at the right time. The reason that they're not documented is that no one's taken the time to spell out the issues, and domain.run(fn) is much easier to get right.

Doc patch welcome, of course.

@hueniverse
Copy link
Author

Is the main concern that there is no symmetry?

enter A, enter B, exit A, exit B - Bad
enter A, enter B, exit B, exit A - Good

@othiym23
Copy link

It's a little more complicated than that; if you do something like a.enter()b.enter()c.enter()a.exit(), both b and c will be exited as well due to how domains nest. So yeah, you have to watch the symmetry, but also you need to be aware of how the nesting works. This is especially important because the nesting rules work for error handling but not for general-purpose state propagation (see #3733 for why this is a problem).

@hueniverse
Copy link
Author

Much appreciated.

othiym23 added a commit to othiym23/node that referenced this issue Aug 3, 2013
bnoordhuis pushed a commit that referenced this issue Aug 5, 2013
Adds the documentation requested in #5017.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants