using/await using rejects bound functions and proxied callables as dispose methods
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, nodejs
- Área
- backend
Línea de trabajo
Empieza ejecutando la reproducción del issue con Node v24.18.0 y leyendo la implementación de V8 / explicit resource management implicada en la búsqueda del método dispose. Compara las comprobaciones callable para funciones ordinarias, enlazadas y proxied con el comportamiento de GetMethod de la propuesta. Se considera terminado cuando los cuatro ejemplos se puedan disponer correctamente, con cobertura de regresión para callables enlazables y proxied.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- JavaScript
- Estrellas
- 122k
- Forks
- 37.4k
- Merge medio
- 4 d 4 h
- PR fusionados (30 d)
- 276
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de nodejs/node
-
doc
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
build
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
feature request
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Todos los issues de nodejs/node
Issues similares
-
bug customer-eng Durable Agents Inngest status: needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
optimization optimization:agents-md-curator
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
githubnext/gh-aw-cao#13475 ·
-
[BUG]: "Clear All" in Settings doesn't clear the saved analysis, old data comes back after reload Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
AOSSIE-Org/OrgExplorer#253 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
oxc-project/oxc#26944 ·
-
ai-observability bug team/ai-observability
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100