openvibers/openvibe.reviews Commits
Await what the transactions start (PostgreSQL pass follow-up): the service's db.tx callback called its async work without awaiting it. A sync callback that calls async code returns before the work is done, so writes could land outside or after their transaction. npm test 15/15.
Changes
@@@ -155,7 +155,7 @@ function createReviewsService({ db, stores, outbox, config, now = () => Date.now// ── Small helpers ────────────────────────────────────────const fail = (status, code, message, extra) => { throw new ReviewsError(status, code, message, extra); };-- const tx = async (fn) => await db.tx(() => fn()); // ambient: plain db calls inside join it++ const tx = async (fn) => await db.tx(async () => await fn()); // ambient: plain db calls inside join itconst entityPath = (e) => `/e/${encodeURIComponent(e.slug)}`;const entityUrl = (e) => seo.canonicalUrl(origin, entityPath(e));const parse = (s, d) => { try { return s == null ? d : JSON.parse(s); } catch { return d; } };
@@ -155,7 +155,7 @@ function createReviewsService({ db, stores, outbox, config, now = () => Date.now
@@ -155,7 +155,7 @@ function createReviewsService({ db, stores, outbox, config, now = () => Date.now
// ── Small helpers ────────────────────────────────────────
// ── Small helpers ────────────────────────────────────────
const fail = (status, code, message, extra) => { throw new ReviewsError(status, code, message, extra); };
const fail = (status, code, message, extra) => { throw new ReviewsError(status, code, message, extra); };
- const tx = async (fn) => await db.tx(() => fn()); // ambient: plain db calls inside join it
+ const tx = async (fn) => await db.tx(async () => await fn()); // ambient: plain db calls inside join it
const entityPath = (e) => `/e/${encodeURIComponent(e.slug)}`;
const entityPath = (e) => `/e/${encodeURIComponent(e.slug)}`;
const entityUrl = (e) => seo.canonicalUrl(origin, entityPath(e));
const entityUrl = (e) => seo.canonicalUrl(origin, entityPath(e));
const parse = (s, d) => { try { return s == null ? d : JSON.parse(s); } catch { return d; } };
const parse = (s, d) => { try { return s == null ? d : JSON.parse(s); } catch { return d; } };