From b330fd24c33bb1bc9b9a5a4d02f4a4a1ea8db4d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Isager=20Dalsgar=C3=B0?= Date: Tue, 26 Nov 2024 14:27:21 +0100 Subject: [PATCH] Adjust ordering --- binding.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/binding.c b/binding.c index afb1d29..5425ce2 100644 --- a/binding.c +++ b/binding.c @@ -109,6 +109,9 @@ bare_timers__on_close(uv_handle_t *handle) { if (--self->active_handles) return; + err = js_finish_deferred_teardown_callback(self->teardown); + assert(err == 0); + err = js_delete_reference(self->env, self->on_timer); assert(err == 0); @@ -117,9 +120,6 @@ bare_timers__on_close(uv_handle_t *handle) { err = js_delete_reference(self->env, self->ctx); assert(err == 0); - - err = js_finish_deferred_teardown_callback(self->teardown); - assert(err == 0); } static void @@ -175,9 +175,6 @@ bare_timers_init(js_env_t *env, js_callback_info_t *info) { uv_unref((uv_handle_t *) &self->check); uv_unref((uv_handle_t *) &self->idle); - err = js_add_deferred_teardown_callback(env, bare_timers__on_teardown, (void *) self, &self->teardown); - assert(err == 0); - err = js_create_reference(env, handle, 1, &self->ctx); assert(err == 0); @@ -187,6 +184,9 @@ bare_timers_init(js_env_t *env, js_callback_info_t *info) { err = js_create_reference(env, argv[1], 1, &self->on_check); assert(err == 0); + err = js_add_deferred_teardown_callback(env, bare_timers__on_teardown, (void *) self, &self->teardown); + assert(err == 0); + return handle; }