-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
async_hooks: rename AsyncLocalStore#enterWith to set #45373
Conversation
The name enterWith indicates that there should be a matching exit but this is not the case. AsyncLocalStore#exit exists but it is not the opponent of enterWith. enterWith() is kept as alias and marked as doc only deprecated.
I actually originally called that function set(...) but there was endless bike shedding around the name as people felt the set(...) naming was confusing too. In any case, I'm good with whatever we want to call it, but my intent with my recent work with diagnostics_channel is to (hopefully) render it as a public interface obsolete. Ideally we should be able to make it internal-only, if my efforts succeed. |
@@ -353,6 +353,9 @@ class AsyncLocalStorage { | |||
} | |||
} | |||
|
|||
// Create deprecated enterWith alias | |||
AsyncLocalStorage.prototype.enterWith = AsyncLocalStorage.prototype.set; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you emit warning when enterWith
is called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Util.deprecate should do the trick
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for not using a doc only deprecation here - at least for a while? Deprecation logs may break apps using the console output.
It's just a about an inoptimum naming not a functional problem which results in some risk/problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd argue we want the deprecation logs to show for a few versions before we remove enterWith
. Alternativelly, we can keep enterWith
and doc it as an alias for set
, but if we want it out, we need to make sure we never break code with . enterWith is not a function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with keeping it as documented alias like I did it here. My main intention is that looking into real world use cases as in the above linked PR the name looks better to me and results in easier to read code.
But enterWith
is not that bad that I would force people to change. can't tell how many users there are actually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe an advantage of enterWith
is that it's "unique" and we can easily search for its usage in GitHub and other open source databases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the main thread, I changed my mind, I think we should keep enterWith
as a forever alias due to its use in existing APMs and we don't want to break any of their customers on whatever version of node x version of the APM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is used extensively at Datadog currently so I definitely would not want to go straight to warning deprecation. We should have a doc deprecation phase, an eventual warning phase, and then maybe removal.
As I stated further up in the issue though, I'm working on making this API (hopefully) obsolete so not sure changes the this will really matter much.
I don't know if we have a precedent of deprecating an experimental API, typically we would simply remove it. I don't know that API, so maybe what I'm saying doesn't make sense, let me know, but what I would suggest would be to introduce |
tbh, I am not a big fan of That said, we have Regarding current use of |
As |
The name
enterWith
indicates that there should be a matching exit but this is not the case.AsyncLocalStore#exit
exists but it is not the opponent ofenterWith
.enterWith()
is kept as alias and marked as doc only deprecated.In special during review of #45277 I found it very confusing the we do
enterWith
in start and exit events.@nodejs/diagnostics @vdeturckheim