mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25:12 +00:00
LibJS: Do not attempt to link modules which have failed to load
Linking a module has assertions about the module's state, namely that the state is not "new". The state remains "new" if loading the module has failed. See: https://tc39.es/ecma262/#figure-module-graph-missing In any case, this exception causes a loading failure, which results in A's [[Status]] remaining new. So we must propagate that failure, instead of blindly moving on to the linking steps.
This commit is contained in:
committed by
Andreas Kling
parent
7d420bbd3d
commit
049109452e
@@ -551,7 +551,10 @@ ThrowCompletionOr<void> VM::link_and_eval_module(Badge<Bytecode::Interpreter>, S
|
||||
ThrowCompletionOr<void> VM::link_and_eval_module(CyclicModule& module)
|
||||
{
|
||||
auto filename = module.filename();
|
||||
module.load_requested_modules(nullptr);
|
||||
auto& promise_capability = module.load_requested_modules(nullptr);
|
||||
|
||||
if (auto const& promise = verify_cast<Promise>(*promise_capability.promise()); promise.state() == Promise::State::Rejected)
|
||||
return JS::throw_completion(promise.result());
|
||||
|
||||
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] Linking module {}", filename);
|
||||
auto linked_or_error = module.link(*this);
|
||||
|
||||
Reference in New Issue
Block a user