using/await using rejects bound functions and proxied callables as dispose methods
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 48/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- javascript, nodejs
- Domaine
- backend
Piste de recherche
Commencez par exécuter la reproduction de l’issue avec Node v24.18.0 et lisez l’implémentation de V8 / explicit resource management impliquée dans la recherche de la méthode dispose. Comparez les vérifications callable pour les fonctions ordinaires, liées et proxied avec le comportement de GetMethod de la proposition. Le travail est terminé lorsque les quatre exemples se disposent correctement, avec une couverture de régression pour les callables liés et proxied.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Version
v24.18.0
Platform
Microsoft Windows NT 10.0.26200.0 x64 (also reproduced on Linux x64 per downstream reports)
Subsystem
V8 / explicit resource management
What steps will reproduce the bug?
const fn = async function () { console.log('disposed'); };
// 1. bound function as async dispose method: throws
try {
await using a = { [Symbol.asyncDispose]: fn.bind(null) };
} catch (e) { console.log('bound async:', e.message); }
// 2. bound function as sync dispose method: throws
try {
using b = { [Symbol.dispose]: (function () {}).bind(null) };
} catch (e) { console.log('bound sync :', e.message); }
// 3. proxy-wrapped callable as dispose method: throws
try {
await using c = { [Symbol.asyncDispose]: new Proxy(fn, {}) };
} catch (e) { console.log('proxied fn :', e.message); }
// 4. ordinary function: works
await using d = { [Symbol.asyncDispose]: fn };
console.log('plain fn accepted');
Output:
bound async: Symbol(Symbol.asyncDispose) is not a function
bound sync : Symbol(Symbol.dispose) is not a function
proxied fn : Symbol(Symbol.asyncDispose) is not a function
plain fn accepted
disposed
What is the expected behavior? Why is that the expected behavior?
All four cases should dispose. Per the Explicit Resource Management proposal, the dispose method is retrieved with GetMethod, which throws only when the value is neither undefined nor callable. Bound function exotic objects and proxies over callables are both callable (typeof reports "function" and they invoke fine), so rejecting them deviates from the spec. It looks like the implementation checks for a specific function instance type rather than IsCallable.
What do you see instead?
TypeError: Symbol(Symbol.asyncDispose) is not a function (respectively Symbol.dispose) at the using declaration site, for values that are callable.
Additional information
Found while debugging unjs/jiti#437: jiti's interopDefault proxy returns bound methods, so any default export with [Symbol.asyncDispose] fails under native await using while typeof mod[Symbol.asyncDispose] === 'function' reports a callable. Downstream is working around it by not binding symbol-keyed methods, but the engine behavior affects any code that binds or proxies dispose methods, which is common in DI containers and instrumentation wrappers.
If this is already tracked in the V8 tracker, a pointer would be appreciated and this can be closed as upstream.
- Langage dominant
- JavaScript
- Étoiles
- 122k
- Forks
- 37.4k
- Merge moyen
- 4 j 3 h
- PR mergées (30 j)
- 279
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de nodejs/node
-
doc
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
-
build
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
-
feature request
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Toutes les issues de nodejs/node
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
palladius/rails8-app-on-gcp#145 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
dotenvx/dotenv-vscode#139 ·
-
test-change-proposal
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
web-platform-tests/interop#1455 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
corsairdev/corsair#1764 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100