openvibers/openvibe.tools Commits

tools.usage: a first record is written with If-Match 0, so two apps creating it at once cannot overwrite each other

OP OpenVibers committed 24 Sept 2026 · aa1389ff4e · 1 file, +1 −1


Changes

ddiff --git a/apps/_shared/usage.js b/apps/_shared/usage.js
iindex ebe8c45..415a98b 100644
---- a/apps/_shared/usage.js
++++ b/apps/_shared/usage.js
@@@ -72,7 +72,7 @@ function createRecorder({ env = process.env, fetchImpl = globalThis.fetch, now =
const had = cur.status === 200 && cur.body && cur.body.data && Array.isArray(cur.body.data.recent) ? cur.body.data.recent : [];
const add = [...fresh].reverse().map(([tool, at]) => ({ tool, at }));
const recent = [...add, ...had.filter((e) => e && !fresh.has(e.tool))].slice(0, MAX);
-- const w = await call('PUT', subject, { body: { data: { recent } }, revision: cur.status === 200 ? cur.body.revision : undefined });
++ const w = await call('PUT', subject, { body: { data: { recent } }, revision: cur.status === 200 ? cur.body.revision : 0 });
if (w.status === 412 || w.status === 409) { stats.conflicts++; return false; }
if (w.status >= 300) throw new Error(`write: ${w.status} ${(w.body && w.body.code) || ''}`);
stats.written++;