Module loading: stale resolution state after failure and pending imports when Promise constructor/species is overridden
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Start in js_resolve_module() in quickjs.c and JS_LoadModuleInternal() near the cited locations. Trace how resolution state changes when dependency loading fails, then inspect perform_promise_then() and its failure handling for internal module reactions. Reproduce both cases from the issue and verify retries leave a consistent module graph and dynamic imports settle after the job queue drains.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Tested against bellard/quickjs commit 712e8c0ca26949477c38f91dbaf955cc48e2f261 (2026-11-02). Both problems reproduce with the unmodified upstream code.
1. Failed dependency resolution leaves a module marked as resolved
Steps to reproduce:
- Install a synchronous module loader that can temporarily fail to load
dep.js. - Compile this module with
JS_EVAL_FLAG_COMPILE_ONLYwhile the dependency is available:import { value } from "./dep.js"; globalThis.answer = value; - Serialize it using
JS_WriteObject(..., JS_WRITE_OBJ_BYTECODE), then deserialize it into a new context usingJS_ReadObject(..., JS_READ_OBJ_BYTECODE). - Make the loader reject
dep.js, then callJS_ResolveModule()on the deserialized module. - Restore the dependency and call
JS_ResolveModule()again. - Execute the module with
JS_EvalFunction().
Actual behavior: The first resolution returns -1. The second returns 0 without loading the dependency, and evaluation crashes with SIGSEGV.
Expected behavior: Failed resolution should leave a consistent module graph. A subsequent resolution should either retry successfully or report an error; it should not report success with unresolved dependency pointers.
In js_resolve_module(), m->resolved is set before traversing dependencies and is not rolled back on failure. Subsequent calls therefore skip the incomplete graph.
2. Dynamic import can remain pending after Promise constructor/species customization
With a valid dep.js containing:
export const value = 42;
Evaluate:
Object.defineProperty(Promise.prototype, "constructor", {
configurable: true,
get() {
return 123;
}
});
globalThis.result = import("./dep.js");
Drain the job queue and inspect result using JS_PromiseState().
Actual behavior: The getter is invoked, and the import promise remains pending after the job queue is empty. The same behavior occurs when overriding Promise[Symbol.species] instead, or when the getter throws. JS_LoadModule() is also affected.
Expected behavior: Registering internal module evaluation reactions should not invoke user-defined Promise constructor/species getters. The import should fulfill with the module namespace.
JS_LoadModuleInternal() calls js_promise_then(), which performs a species lookup. If that lookup fails, the returned exception is discarded and the outer promise is never settled. Using the internal perform_promise_then() mechanism, with appropriate failure handling, should avoid this lookup.
- Lingua principale
- C
- Stelle
- 11.1k
- Fork
- 1.2k
- Merge medio
- 11h 20m
- PR unite (30g)
- 1
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di bellard/quickjs
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
bellard/quickjs#602 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di bellard/quickjs
Issue simili
-
要トリアージ 辞書
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
yksr-melt/Meltype#1625 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
[yugabyted] xcluster set_up and add_to_replication fail for database names containing - . or (Apertakind/bug priority/medium qa_automation
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
yugabyte/yugabyte-db#37324 ·
I maintainer di solito rispondono entro 1 giorno
-
Add CMake export targetAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
tree-sitter/tree-sitter#6111 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
meshcore-dev/MeshCore#3781 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
ly05010419/MacNativeGames#1897 ·
I maintainer di solito rispondono entro 1 giorno