Conversation
doc/api/process.md
Outdated
lib/internal/process.js
Outdated
There was a problem hiding this comment.
kIsExitingSymbol? kIsExiting suggests it's a boolean.
There was a problem hiding this comment.
Aren't we using kAnything to signify symbols where, I assume, k === key? At the very least, http2, tls & url already do it that way.
lib/internal/process/next_tick.js
Outdated
There was a problem hiding this comment.
I would expect this to introduce a performance regression (getter that calls into the C++ runtime.) Have you run next-tick benchmarks?
There was a problem hiding this comment.
Perhaps rather than a getter here, a public read-only property should be added only when we are exiting... that is.. setIsExiting() could do something like...
Object.defineProperty(process, 'exiting', { configurable: false, enumerable: true, value: true });This should largely avoid the perf regression on calling the getter multiple times.
There was a problem hiding this comment.
@jasnell If it weren't there prior to exiting, then it could be set by userland code long before exiting, causing the problems I was trying to solve.
Maybe a getter to something in internal/process? That way it still would be userland tamper-proof, but wouldn't dive into C++.
There was a problem hiding this comment.
That would certainly be better but the getter still comes at a cost.... hmm will have to think about it a bit more.
There was a problem hiding this comment.
nextTick could just use the actual value on internal/process, rather than the getter (which would be only for public use).
There was a problem hiding this comment.
@bengl if I understand you correct you want to use a plain symbol in internal/process plus the isExiting property as getter that exposes that symbol?
|
Why expose this publicly now? The only code that can run during exist is within If anything we should make the property non-writable-configurable or just hide it entirely... |
For one, it tells you whether there’s a chance async operations that you schedule will finish or not.
Yes, it should tell you exactly that – whether you’re inside an |
|
Defensively marking as semver-major. I've seen code in the wild that looks at |
Yes, I’d think so. It doesn’t really cost anything to keep that around, right? |
doc/api/process.md
Outdated
There was a problem hiding this comment.
- even -> event?
- Maybe it is worth to add a type before the description for consistency with other properties:
* {boolean}
doc/api/process.md
Outdated
There was a problem hiding this comment.
Aside: Maybe some of the cool new md linting can get a custom rule to validate these YAML bits? /cc @watilde
doc/api/process.md
Outdated
There was a problem hiding this comment.
"tells whether" -> "indicates if"?
|
I am wondering if we really need to expose this at all... I am not a huge fan of adding functionality that was never requested. Does someone have a use case for me right quick? |
|
I'm + 1 on adding this and keeping the |
Or indefinitely. ;) |
|
ping @bengl again |
This replaces the previously undocumented `_exiting` property with a read-only property giving the same information. Setting the property is restricted to internals, to prevent tampering. Tampering could affect nextTick behavior, for example.
fc062cc to
1b7a9bf
Compare
|
I've updated this with the requested changes, however, as @bnoordhuis suggested, |
|
@bengl If necessary, there’s always the option of falling back to just renaming it, right? I would prefer that over trying to protect it from user access at all costs. |
|
@addaleax Yeah, I'd definitely prefer to prevent user tampering, but the added overhead of having to pass an extra reference in so I'll do another PR in a bit, just adding the alias and documenting it. |
|
@bengl is this still work in progress? And it needs a rebase. |
|
Closing due to long inactivity. Please feel free to reopen if you would like to work on this again. |
This replaces the previously undocumented
_exitingproperty with aread-only property giving the same information. Setting the property is
restricted to internals, to prevent tampering. Tampering could affect
nextTick behavior, for example.
Twitter thread for context: https://twitter.com/bengl/status/922361992379166721
It may or may not make sense to keep
_exitingaround as an alias, if there's userland code using it. That's easy enough to do if reviewers would like that./cc @addaleax @Trott
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
process