From 191eade127f032f5f7d50f8fea817c2032ba9485 Mon Sep 17 00:00:00 2001 From: Hans Klunder Date: Sat, 22 Mar 2025 11:52:05 +0100 Subject: [PATCH] fix: fix waitForReady --- abstract.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/abstract.js b/abstract.js index c848887..9b9b0eb 100644 --- a/abstract.js +++ b/abstract.js @@ -310,13 +310,16 @@ function abstractPersistence (opts) { const instance = await _persistence() if (instance) { + // instance.broker must be set first because setting it triggers + // the call of instance._setup if aedes-cached-persistence is being used + // instance._setup then fires the 'ready'event + instance.broker = broker // Wait for ready event, if applicable, to ensure the persistence isn't // destroyed while it's still being set up. // https://github.com/mcollina/aedes-persistence-redis/issues/41 if (waitForReady) { await waitForEvent(instance, 'ready') } - instance.broker = broker t.diagnostic('instance created') return instance }