@@ -362,7 +362,13 @@ void HvJsPromiseOp::cancel(const char* reason) {
362362HvJsRuntime* hvjs_runtime (hloop_t * loop, const HvJsRuntimeOptions& options) {
363363 if (loop == NULL ) return NULL ;
364364 HvJsRuntime* runtime = (HvJsRuntime*)hloop_js_runtime (loop);
365- if (runtime) return runtime;
365+ if (runtime) {
366+ if (runtime->options .memory_limit != options.memory_limit || runtime->options .stack_size != options.stack_size ) {
367+ hlogw (" [js] QuickJS runtime already exists on this hloop; ignoring new memory_limit=%llu stack_size=%llu" ,
368+ (unsigned long long )options.memory_limit , (unsigned long long )options.stack_size );
369+ }
370+ return runtime;
371+ }
366372
367373 runtime = new HvJsRuntime ();
368374 runtime->options = options;
@@ -402,11 +408,11 @@ void hvjs_task_unref(HvJsTask* task) {
402408 }
403409 }
404410 finish_deferred_ops (task);
405- if (!JS_IsUndefined (task->promise_result )) {
411+ if (task-> js && !JS_IsUndefined (task->promise_result )) {
406412 JS_FreeValue (task->js , task->promise_result );
407413 task->promise_result = JS_UNDEFINED ;
408414 }
409- if (!JS_IsUndefined (task->promise )) {
415+ if (task-> js && !JS_IsUndefined (task->promise )) {
410416 JS_FreeValue (task->js , task->promise );
411417 task->promise = JS_UNDEFINED ;
412418 }
@@ -469,9 +475,7 @@ bool hvjs_task_start_timeout(HvJsTask* task, int timeout_ms) {
469475void hvjs_task_cancel_timeout (HvJsTask* task) {
470476 if (task == NULL ) return ;
471477 if (task->timeout_timer_id != INVALID_TIMER_ID && task->loop_ptr ) {
472- if (task->loop_ptr ->isRunning ()) {
473- task->loop_ptr ->killTimer (task->timeout_timer_id );
474- }
478+ task->loop_ptr ->killTimer (task->timeout_timer_id );
475479 task->timeout_timer_id = INVALID_TIMER_ID ;
476480 hvjs_task_unref (task);
477481 }
0 commit comments