core: Minor cleanup.

This commit is contained in:
2025-12-07 08:25:55 -05:00
parent 14955fa421
commit 2086075f7b
3 changed files with 15 additions and 26 deletions

View File

@@ -237,16 +237,19 @@ static void _httpd_auth_query_work(tf_ssb_t* ssb, void* user_data)
static void _httpd_app_kill_task(app_t* work)
{
JSContext* context = work->request->context;
if (!JS_IsUndefined(work->process))
if (JS_IsObject(work->process))
{
JSValue task = JS_GetPropertyStr(context, work->process, "task");
if (!JS_IsUndefined(task))
if (JS_IsObject(task))
{
JSValue kill = JS_GetPropertyStr(context, task, "kill");
JSValue result = JS_Call(context, kill, task, 0, NULL);
tf_util_report_error(context, result);
JS_FreeValue(context, result);
JS_FreeValue(context, kill);
if (!JS_IsUndefined(kill))
{
JSValue result = JS_Call(context, kill, task, 0, NULL);
tf_util_report_error(context, result);
JS_FreeValue(context, result);
JS_FreeValue(context, kill);
}
}
JS_FreeValue(context, task);
}

View File

@@ -227,14 +227,12 @@ bool tf_util_report_error(JSContext* context, JSValue value)
tf_printf("ERROR: %s\n", string);
JS_FreeCString(context, string);
JSValue stack = JS_GetPropertyStr(context, value, "stack");
if (!JS_IsUndefined(stack))
const char* stack = tf_util_get_property_as_string(context, value, "stack");
if (stack && *stack)
{
const char* stack_str = JS_ToCString(context, stack);
tf_printf("%s\n", stack_str);
JS_FreeCString(context, stack_str);
tf_printf("%s\n", stack);
}
JS_FreeValue(context, stack);
JS_FreeCString(context, stack);
tf_task_send_error_to_parent(task, value);
is_error = true;