From 554ea683a33f49dac085d872e1335d9354152138 Mon Sep 17 00:00:00 2001 From: E M <5089238+emizzle@users.noreply.github.com> Date: Mon, 23 Mar 2026 16:20:28 +1100 Subject: [PATCH] remove unneeded keepalives --- tests/js/harness.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/tests/js/harness.js b/tests/js/harness.js index 3c5c1cf6..fda82dc2 100644 --- a/tests/js/harness.js +++ b/tests/js/harness.js @@ -163,26 +163,21 @@ export class StorageNode { * Resolves when the node is ready (storage_new callback fires RET_OK). */ async create(configJson) { - let cb; - const promise = new Promise((resolve, reject) => { - const keepAlive = setInterval(() => {}, 200); - - cb = koffi.register((ret, msg, _len, _userData) => { - clearInterval(keepAlive); + return new Promise((resolve, reject) => { + let cb = koffi.register((ret, msg, _len, _userData) => { koffi.unregister(cb); if (ret === RET_OK) resolve(); else reject(new Error(msg ?? 'storage_new callback failed')); }, koffi.pointer(StorageCallback)); + + this.#ctx = _lib.storage_new(configJson, cb, null); + + if (!this.#ctx) { + koffi.unregister(cb); + throw new Error('storage_new returned null — check configJson'); + } + }); - - this.#ctx = _lib.storage_new(configJson, cb, null); - if (!this.#ctx) { - koffi.unregister(cb); - throw new Error('storage_new returned null — check configJson'); - } - - await promise; - return this; } /** Returns the version string synchronously (e.g. "v0.3.2") */