Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions NativeScript/runtime/ModuleInternal.mm
Original file line number Diff line number Diff line change
Expand Up @@ -885,11 +885,21 @@ ScriptOrigin origin(isolate, urlString, 0, 0, false, -1, Local<Value>(), false,
if (state == Promise::kRejected) {
RemoveModuleFromRegistry(canonicalPath);
logPhase("evaluate", "promise-rejected");
if (!promiseTc.HasCaught()) {
// With top-level-await semantics, evaluation errors don't throw into
// the TryCatch — they surface only as the rejection reason of the
// evaluation promise. Re-throw the reason on the isolate so the
// TryCatch captures it and the exception below carries the original
// error message and stack trace instead of a synthetic placeholder.
isolate->ThrowException(promise->Result());
}
if (promiseTc.HasCaught()) {
if (RuntimeConfig.IsDebug) {
Log(@"Error evaluating ES module (rejected promise): %s", canonicalPath.c_str());
tns::LogError(isolate, promiseTc);
}
throw NativeScriptException(isolate, promiseTc, "Module evaluation promise rejected");
} else {
Local<Value> reason = promise->Result();
isolate->ThrowException(reason);
throw NativeScriptException(isolate, "Module evaluation promise rejected");
}
}
Expand Down
Loading