Expose dynamic compile failures
This commit is contained in:
+24
-4
@@ -2995,12 +2995,15 @@ private:
|
||||
// `handler` names the export ("render", "component:CARD", "cli",
|
||||
// "serve_http:named", "once") or is "exists" (probe only, loads nothing).
|
||||
int32_t component_resolve(const String& target, const String& handler, const String& current_unit,
|
||||
String& resolved_out, int32_t* once_slot_out = 0, bool* compile_timed_out = 0)
|
||||
String& resolved_out, int32_t* once_slot_out = 0, bool* compile_timed_out = 0,
|
||||
String* compile_error_out = 0)
|
||||
{
|
||||
if(once_slot_out)
|
||||
*once_slot_out = 0;
|
||||
if(compile_timed_out)
|
||||
*compile_timed_out = false;
|
||||
if(compile_error_out)
|
||||
compile_error_out->clear();
|
||||
auto probe_start = std::chrono::steady_clock::now();
|
||||
auto record_probe = [&]() {
|
||||
component_resolve_count += 1;
|
||||
@@ -3130,10 +3133,22 @@ private:
|
||||
{
|
||||
u64 remaining_ms = invocation_remaining_ms();
|
||||
bool timed_out = false;
|
||||
SharedUnit* compiled_unit = 0;
|
||||
if(remaining_ms == 0)
|
||||
timed_out = true;
|
||||
else
|
||||
get_shared_unit_bounded(context, resolved, remaining_ms, &timed_out);
|
||||
compiled_unit = get_shared_unit_bounded(context, resolved, remaining_ms, &timed_out);
|
||||
if(compiled_unit && compile_error_out &&
|
||||
to_bool(context->server->config["SHOW_DYNAMIC_COMPILE_ERRORS"], true))
|
||||
{
|
||||
String detail = trim(first(compiled_unit->compiler_messages, compiled_unit->compile_error_status));
|
||||
if(detail != "")
|
||||
{
|
||||
*compile_error_out = "compile failed for " + resolved + ":\n" + detail;
|
||||
if(compile_error_out->size() > 4095)
|
||||
*compile_error_out = compile_error_out->substr(0, 4064) + "\n[compile error truncated]";
|
||||
}
|
||||
}
|
||||
if(timed_out)
|
||||
{
|
||||
if(compile_timed_out)
|
||||
@@ -4521,15 +4536,20 @@ private:
|
||||
}));
|
||||
if(mod == "env" && name == "uce_host_component_resolve")
|
||||
return(add([self](Caller caller, Span<const Val> args, Span<Val> results) -> Result<std::monostate, Trap> {
|
||||
String target, handler, current, resolved;
|
||||
String target, handler, current, resolved, compile_error;
|
||||
self->hostcall_read(args[0].i32(), args[1].i32(), target);
|
||||
self->hostcall_read(args[2].i32(), args[3].i32(), handler);
|
||||
self->hostcall_read(args[4].i32(), args[5].i32(), current);
|
||||
int32_t once_slot = 0;
|
||||
bool compile_timed_out = false;
|
||||
int32_t slot = self->component_resolve(target, handler, current, resolved, &once_slot, &compile_timed_out);
|
||||
int32_t slot = self->component_resolve(target, handler, current, resolved, &once_slot, &compile_timed_out, &compile_error);
|
||||
if(compile_timed_out)
|
||||
return(Trap(self->invocation_timeout_error()));
|
||||
if(slot == 0 && compile_error != "")
|
||||
{
|
||||
resolved = compile_error;
|
||||
slot = -1;
|
||||
}
|
||||
u32 cap = (u32)args[7].i32();
|
||||
if(cap > 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user