diff --git a/core/core.js b/core/core.js index 272b25e5..af7ea016 100644 --- a/core/core.js +++ b/core/core.js @@ -249,7 +249,11 @@ async function getProcessBlob(blobId, key, options) { } await process.task.execute({name: blobId, source: appSource}); } catch (error) { - printError({print: print}, error); + if (process.app) { + process.app.send({action: 'error', error: error}); + } else { + printError({print: print}, error); + } rejectReady(); } } diff --git a/src/serialize.c b/src/serialize.c index 671a2aa9..13e3a572 100644 --- a/src/serialize.c +++ b/src/serialize.c @@ -243,10 +243,6 @@ static bool _serialize_storeInternal(tf_task_t* task, tf_taskstub_t* to, buffer_ { JS_SetPropertyStr(context, error, "message", message); } - else - { - JS_FreeValue(context, message); - } if (JS_IsError(context, exception)) { JSValue stack = JS_GetPropertyStr(context, exception, "stack"); diff --git a/src/task.c b/src/task.c index 1407b8ae..1492b797 100644 --- a/src/task.c +++ b/src/task.c @@ -765,10 +765,17 @@ void tf_task_on_receive_packet(int packetType, const char* begin, size_t length, JSValue utf8 = tf_util_utf8_decode(to->_context, source); const char* source_str = JS_ToCString(to->_context, utf8); JS_FreeValue(to->_context, utf8); - _tf_task_executeSource(to, source_str, name); + JSValue result = _tf_task_executeSource(to, source_str, name); + if (JS_IsException(result)) + { + _tf_task_sendPromiseReject(to, from, promise, JS_GetException(to->_context)); + } + else + { + _tf_task_sendPromiseResolve(to, from, promise, result); + } JS_FreeCString(to->_context, source_str); JS_FreeCString(to->_context, name); - _tf_task_sendPromiseResolve(to, from, promise, JS_UNDEFINED); } break; case kKill: @@ -930,12 +937,14 @@ static JSValue _tf_task_executeSource(tf_task_t* task, const char* source, const { tf_trace_begin(task->_trace, "_tf_task_executeSource"); JSValue result = JS_Eval(task->_context, source, strlen(source), name, 0); - tf_util_report_error(task->_context, result); if (!*task->_scriptName) { snprintf(task->_scriptName, sizeof(task->_scriptName), "%s", name); } - tf_task_run_jobs(task); + if (!JS_IsException(result)) + { + tf_task_run_jobs(task); + } tf_trace_end(task->_trace); return result; }