From cef6c7af78c772d6cffd5cc5e3d3fec74666862e Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Sun, 22 Sep 2024 15:26:23 -0700 Subject: [PATCH] netlify --- src/blockstore/store-meta.ts | 10 ++++++++-- tests/fireproof/all-gateway.test.ts | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/blockstore/store-meta.ts b/src/blockstore/store-meta.ts index d9cf2028..4e824692 100644 --- a/src/blockstore/store-meta.ts +++ b/src/blockstore/store-meta.ts @@ -114,8 +114,14 @@ export class MetaStoreImpl extends BaseStoreImpl implements MetaStore { ensureLogger(sthis, "MetaStoreImpl"), ); if (remote && opts.gateway.subscribe) { - this.logger.Debug().Str("url", url.toString()).Msg("Subscribing to the gateway"); - opts.gateway.subscribe(url, (message: Uint8Array) => decodeGatewayMetaBytesToDbMeta(this.sthis, message)); + this.onStarted(async () => { + this.logger.Debug().Str("url", this.url().toString()).Msg("Subscribing to the gateway"); + opts.gateway.subscribe?.(this.url(), async (message: Uint8Array) => { + this.logger.Debug().Msg("Received message from gateway"); + const dbMetas = await decodeGatewayMetaBytesToDbMeta(this.sthis, message); + await this.loader?.handleDbMetasFromStore(dbMetas.map((m) => m.dbMeta)); + }); + }); } } diff --git a/tests/fireproof/all-gateway.test.ts b/tests/fireproof/all-gateway.test.ts index b00e04f6..20675008 100644 --- a/tests/fireproof/all-gateway.test.ts +++ b/tests/fireproof/all-gateway.test.ts @@ -388,6 +388,7 @@ describe("Gateway", function () { it("should delete data from Meta Gateway", async function () { const metaUrl = await metaGateway?.buildUrl(metaStore?._url, "main"); await metaGateway?.start(metaStore?._url); + // should we be testing .destroy() instead? const metaDeleteResult = await metaGateway?.delete(metaUrl?.Ok()); expect(metaDeleteResult?.Ok()).toBeFalsy(); });