You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The docs aren't entirely clear on the purpose of the second optional argument (resource), how it's supposed to be used, or when it's useful. One of the primary use cases for this util function seems to be aborting a promise that doesn't support abort natively, but I'm not sure what I should pass as the resource?
import{aborted}from'node:util';constac=newAbortController();constclient=newSomeRandomDatabaseClient();constresults=awaitPromise.race([client.uncancelableQuery(),aborted(ac.signal,/* what am i supposed to pass here */),]);// somewhere else ac.abort() may or may not ever be called// but assume ac does go out of scope and get gc'd eventually
Am I thinking about this use case correctly, or is not passing resource somehow creating a memory leak / preventing things from being cleaned up properly?
EDIT: It seems I misunderstood the second argument being optional, it appears required, but questions still remain how it's supposed to be used for the example above.
The text was updated successfully, but these errors were encountered:
Affected URL(s)
https://nodejs.org/api/util.html#utilabortedsignal-resource
Description of the problem
The docs aren't entirely clear on the purpose of the second
optionalargument (resource
), how it's supposed to be used, or when it's useful. One of the primary use cases for this util function seems to be aborting a promise that doesn't support abort natively, but I'm not sure what I should pass as the resource?Am I thinking about this use case correctly, or is not passing resource somehow creating a memory leak / preventing things from being cleaned up properly?
EDIT: It seems I misunderstood the second argument being optional, it appears required, but questions still remain how it's supposed to be used for the example above.
The text was updated successfully, but these errors were encountered: