This commit is contained in:
Raven Scott
2026-05-27 20:15:25 -04:00
parent 05e388d525
commit b000e34016
3 changed files with 26 additions and 31 deletions
+19
View File
@@ -49,6 +49,24 @@ async function ensureDnsPassOpen(pass) {
return true;
}
async function waitForAutobaseIdle(pass, timeoutMs = 5000) {
const base = pass && pass.base;
if (!base) return false;
const start = Date.now();
while (Date.now() - start < timeoutMs) {
const flushing = typeof base._flushing === 'number' ? base._flushing > 0 : false;
const fastForwarding = typeof base.isFastForwarding === 'function' ? base.isFastForwarding() : false;
if (!base.updating && !base.appending && !flushing && !fastForwarding && !base.closing) {
return true;
}
await sleep(100);
}
logWarn('DnsPassQueue', 'Autobase did not become idle before dnsPass operation; proceeding cautiously');
return false;
}
function enqueueDnsPass(operation) {
const run = chain.then(async () => {
state.dnsPassWriteInProgress = (state.dnsPassWriteInProgress || 0) + 1;
@@ -82,6 +100,7 @@ async function createInvite(pass, opts) {
if (!(await ensureDnsPassOpen(pass))) {
throw new Error('dnsPass not open');
}
await waitForAutobaseIdle(pass);
logDebug('DnsPassQueue', 'createInvite: starting');
try {
return await withTimeout(