import.meta in any non-builtin module fails with "uncaught exception: undefined" (module_metadata_hook returns false without an exception)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- c, javascript, wasm
- Área
- backend
Línea de trabajo
Empieza en runtime/script_loader.cpp, en module_metadata_hook, donde el issue identifica la devolución de false para los módulos ordinarios como la causa. Revisa las pruebas de carga de módulos y añade un caso de regresión que evalúe typeof import.meta en un módulo de usuario. El issue está resuelto cuando la evaluación de módulos ordinarios tiene éxito y el caso de regresión pasa; los módulos integrados deben conservar su comportamiento de import.meta.builtin.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
Evaluating import.meta in a user module aborts the module with an uncatchable error, because the module metadata
hook returns false without setting an exception. try/catch around it does not help. In a ComponentizeJS component
the exported function traps.
Environment
- StarlingMonkey v0.4.0 release
starling.wasm, wasmtime 50.0.1, module mode (wasmtime run -S http --dir . starling.wasm main.js). runtime/script_loader.cppis unchanged onmain(54b3329b).- Also seen with
@bytecodealliance/componentize-js0.23.0. - Checked on 2026-11-03. Reference: SpiderMonkey jsshell 147.0.4 (the SpiderMonkey version StarlingMonkey v0.4.0 embeds),
js -m.
Reproduction
// main.js
console.log(typeof import.meta);
console.log(import.meta.url);
StarlingMonkey:
Exception while evaluating top-level script
uncaught exception: undefined
Additionally, some promises were rejected, but the rejection never handled:
Promise rejected but never handled: (void 0)
jsshell prints object and the module's location. The same failure happens in an imported (non-entry) module, and
when the access is wrapped in try { … } catch (e) { … }: neither the catch block nor the code after it runs.
ComponentizeJS 0.23.0:
export function run() {
try { return typeof import.meta + " " + import.meta.url; } catch (e) { return "threw " + e; }
}
wasmtime run -S http --invoke 'run()' component.wasm prints uncaught exception: undefined and the instance traps
(wasm 'unreachable' instruction executed).
test262: language/expressions/import.meta/same-object-returned.js and import-meta-is-an-ordinary-object.js fail
the same way.
Expected
import.meta is an ordinary object and evaluating it does not throw
(spec). The host hooks
HostGetImportMetaProperties and
HostFinalizeImportMeta return a List / nothing, not a
completion, so they cannot fail. Hosts may add properties such as url.
Cause
runtime/script_loader.cpp:
bool module_metadata_hook(JSContext *cx, HandleValue ref_priv, HandleObject meta_obj) {
...
RootedValue builtin_val(cx);
if (!MapGet(cx, builtinModules, parent_id_val, &builtin_val)) {
return false;
}
if (builtin_val.isUndefined()) {
return false; // every non-builtin module ends up here, with no pending exception
}
JS_SetProperty(cx, meta_obj, "builtin", builtin_val);
return true;
}
The hook exists to give builtin modules import.meta.builtin. For ordinary modules it returns false, which
SpiderMonkey treats as an uncatchable error. (The !parent_id_val.isString() branch has the same problem.)
Suggested fix
if (builtin_val.isUndefined()) {
return true; // ordinary module: nothing to add
}
Optionally also set import.meta.url (as a file:// URL built from the resolved module path) and
import.meta.resolve, as other hosts do. A regression test is console.log(typeof import.meta) in a user module.
- Lenguaje dominante
- C
- Estrellas
- 297
- Forks
- 64
- Merge medio
- 2 d 2 h
- PR fusionados (30 d)
- 19
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 bytecodealliance/StarlingMonkey
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
bytecodealliance/StarlingMonkey#359 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 1-2 días Aptitud para principiantes 68/100
bytecodealliance/StarlingMonkey#358 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
bytecodealliance/StarlingMonkey#357 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
bytecodealliance/StarlingMonkey#356 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 44/100
bytecodealliance/StarlingMonkey#354 ·
Los mantenedores suelen responder en 1 día
Todos los issues de bytecodealliance/StarlingMonkey
Issues similares
-
contrib/ivorysql_ora/src/builtin_packages/utl_file/utl_file.c:517 - FCOPY destroys a file when source and destination are the samePosiblemente ocupada @Metastarx la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
ly05010419/MacNativeGames#1848 ·
Los mantenedores suelen responder en 1 día
-
libc++ test-suite
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
llvm/llvm-project#239851 ·
Los mantenedores suelen responder en 1 día
-
Missing input validationAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
-
bug game: 010042D00D900000 mac
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día