diff --git a/src/taskstub.js.c b/src/taskstub.js.c index 3c7f7cd7..0844dfbd 100644 --- a/src/taskstub.js.c +++ b/src/taskstub.js.c @@ -291,12 +291,14 @@ static void _taskstub_on_process_exit(uv_process_t* process, int64_t status, int JSContext* context = tf_task_get_context(stub->_owner); if (!JS_IsUndefined(stub->_on_exit)) { + JSValue ref = JS_DupValue(context, stub->_on_exit); JSValue argv[] = { JS_NewInt32(context, status), JS_NewInt32(context, terminationSignal) }; JSValue result = JS_Call(context, stub->_on_exit, JS_NULL, 2, argv); tf_util_report_error(context, result); JS_FreeValue(context, result); JS_FreeValue(context, argv[0]); JS_FreeValue(context, argv[1]); + JS_FreeValue(context, ref); } if (stub->_stream) {