Uncaught TypeError when assigning null to xhr.onreadystatechange/onprogress (breaks hls.js abort)
@cyhano ya está trabajando en esto.
Desde el 15/9/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 85/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
Línea de trabajo
Comienza en src/network/xhr.proxy.ts e inspecciona setOnReadyStateChange, setOnAbort y setOnTimeout. Reproduce el problema con el fragmento de XMLHttpRequest proporcionado y verifica después que asignar null o undefined no provoque el envoltorio del callback ni una excepción durante el aborto.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
Libraries like hls.js clear XHR event callbacks before aborting in-flight requests (see XhrLoader.abortInternal in hls.js):
xhr.onreadystatechange = null;
xhr.onprogress = null;
xhr.abort();
With vConsole enabled, this throws an uncaught TypeError, because the XHR proxy wraps whatever value is assigned to onreadystatechange / onabort / ontimeout without a null check — the wrapper later calls value.apply(...) on null.
src/network/xhr.proxy.ts (still present on current master):
protected setOnReadyStateChange(target: T, key: string, value) {
...
Reflect.set(target, key, function () {
...
value.apply(target, args); // 💥 value may be null
});
}
// setOnAbort / setOnTimeout have the same problem
Assigning null to these callbacks is a legitimate, spec-compliant way to remove them, so the proxy should pass null through instead of wrapping it.
Steps to reproduce
<script src="https://unpkg.com/[email protected]/dist/vconsole.min.js"></script>
<script>
new VConsole();
var xhr = new XMLHttpRequest();
xhr.open('GET', '/'); // any URL
xhr.onreadystatechange = function () {};
xhr.send();
xhr.onreadystatechange = null; // how hls.js abortInternal cleans up
xhr.onprogress = null;
xhr.abort(); // → Uncaught TypeError: Cannot read properties of null (reading 'apply')
</script>
Running the exact same code without vConsole produces no error (verified side by side).
Real-world impact
Any page playing HLS video via hls.js throws this on every stream switch / stop / destroy:
Uncaught TypeError: Cannot read property 'apply' of null
at XMLHttpRequest.<anonymous> (vconsole.js)
at t.r.abortInternal (hls.min.js)
at t.abort (hls.min.js)
at e.t.abort (hls.min.js)
at t.r.stopLoad (hls.min.js)
...
Environment
- vConsole version: 3.15.1 (latest release; null check also missing on current master)
- Browser: any (reproduced in Chrome)
Suggested fix
Pass null/undefined through instead of wrapping it, in all three setters:
protected setOnReadyStateChange(target: T, key: string, value) {
if (!value) return Reflect.set(target, key, value);
...
}
- Lenguaje dominante
- TypeScript
- Estrellas
- 17.5k
- Forks
- 3k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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 Tencent/vConsole
-
[Network] fetch proxy 读取分块流到 EOF 时抛 TypeError: Cannot read properties of undefined (reading 'length')Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
Prototype Pollution in network.model.tsPosiblemente ocupada @dvd233 la tomó hace 77 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
不发新版 npm 包了吗Abierto
Dificultad 2/5 Menos de una hora Aptitud para principiantes 15/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
处理流式数据的错误报警Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
Todos los issues de Tencent/vConsole
Issues similares
-
status: triage type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
WhiteTowerAI/ohmygame#1225 ·
Los mantenedores suelen responder en 1 día
-
Add: KBS TV SDAbiertostreams:add
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
ardia-browser/ardia#5042 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
keycloakify/oidc-spa#211 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día