-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
AsyncResource constructor arguments #46369
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
Comments
Seems reasonable to me. Possibly related though, and we've already discussed a bit privately, is the idea of |
I think that makes sense but I'd hesitate to have to create new API surface at this point with |
As long as async_hooks is still a thing and has use cases no covered by Some people use async_hooks for resource tracking and it's valuable to have a good name there. As these tracking tools and the creators of If someone creates a derived class it's just a matter to pass it to Even if we create a replacement API for resource tracking I would assume the resource type is valueable info there. |
I agree that the value is useful for |
Frequently the consumer of this info (APM tool, logger, crash analyser,...) is not the same person as the creator of the AsyncResource (DB driver,...). As a result the consumer gets bad data and the final user of this tool complains that it is not helpful. sure, a PR on the producer repo is always possible but why should we go this rocky path just because of a single string given to a constructor? |
Largely because it simply adds friction for other runtime implementations that want to implement Async context tracking in a portable way but have no intention of implementing async hooks in general. The name is generally not useful for those cases an requiring that it be there and be a non-empty string is a nuisance (admittedly a small one) |
AsyncContext includes a |
Keeping the name in other runtimes allows to add a resource tracking later. |
I don't think resource tracking should ever be a concern of AsyncLocalStorage or AsyncContext. They are two different concepts and never should have been mashed together like they were with async_hooks. A proper resource tracking API should exist separately. |
As far as workerd/cloudflare workers is concerned, we never intend to implement |
Fully agree but this issue is about |
|
So you propose to put away the e.g. add (or rename to) |
No, we don't want to rename the class. I simply want to default the |
I didn't meant to rename. Add |
As I've said, I do not really want to introduce new API surface while @Qard has mentioned a few times about adding a static |
Agree. |
Uh oh!
There was an error while loading. Please reload this page.
Currently, the
AsyncResource
constructor requires atype
argument, e.g.new AsyncResource('foo')
. It will throw if this is not provided. This information, however, is only used for async_hooks integration and is not necessary for async context propagation. I'd like to propose that we make the argument optional, defaulting its value tothis.constructor?.name || 'AsyncResource'
when it is not provided./cc @Qard @legendecas @nodejs/async_hooks
The text was updated successfully, but these errors were encountered: