chore: upgrade @orbito/api-lib to 3.3.3

Lock TTL is now passed in seconds, matching what the core lock RPC methods
expect and what the 3.x SDK documents as ttlSeconds.

The presta-api timeout test no longer drains the event loop: it drives the
unref-ed timeout timer through node:test mock timers instead of real ones.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LpoFvfAbnMmkSJFRc867XA
This commit is contained in:
2026-09-10 12:04:32 +02:00
co-authored by Claude Opus 5
parent ac64072f1b
commit 7e84524714
6 changed files with 57 additions and 15 deletions
+13 -4
View File
@@ -13,21 +13,30 @@ function createJobRuntime(Core, Log = console) {
return promise;
}
async function withRenewedLock(lockName, ttlMs, operation) {
const lockId = await Core.getLock(lockName, ttlMs);
/**
* Uruchamia operację pod rozproszonym lockiem, odnawiając go w tle.
*
* @param {string} lockName - Nazwa locka
* @param {number} ttlSeconds - TTL locka w SEKUNDACH (jednostka wymagana przez Core.getLock/Core.extendLockTime)
* @param {(isLockValid: () => boolean) => Promise<*>} operation - Operacja do wykonania pod lockiem
*/
async function withRenewedLock(lockName, ttlSeconds, operation) {
const lockId = await Core.getLock(lockName, ttlSeconds);
if (!lockId) return null;
let lockValid = true;
let renewal = null;
// Odnawiamy trzy razy częściej niż wynosi TTL; setInterval oczekuje milisekund.
const renewIntervalMs = Math.max(1000, Math.floor(ttlSeconds * 1000 / 3));
const timer = setInterval(() => {
if (renewal || !lockValid) return;
renewal = Core.extendLockTime(lockId, ttlMs)
renewal = Core.extendLockTime(lockId, ttlSeconds)
.catch(error => {
lockValid = false;
Log.error('PrestaShop cron lock renewal failed', { lockName, error: error.message });
})
.finally(() => { renewal = null; });
}, Math.max(1000, Math.floor(ttlMs / 3)));
}, renewIntervalMs);
timer.unref?.();
try {