MCPcopy Create free account
hub / github.com/chhoumann/quickadd / waitForInstanceReady

Function waitForInstanceReady

scripts/start-obsidian-e2e-instance.mjs:347–369  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

345}
346
347export async function waitForInstanceReady(options) {
348 const expectedPath = path.resolve(options.vaultPath);
349 const deadline = Date.now() + READY_TIMEOUT_MS;
350 let lastError = "";
351
352 while (Date.now() < deadline) {
353 try {
354 const { stdout } = await execObsidian(options, [
355 `vault=${options.vaultName}`,
356 "vault",
357 "info=path",
358 ]);
359 const actualPath = path.resolve(stdout.trim());
360 if (actualPath === expectedPath) return actualPath;
361 lastError = `resolved ${actualPath}, expected ${expectedPath}`;
362 } catch (error) {
363 lastError = error?.stderr?.trim() || error?.stdout?.trim() || error?.message || String(error);
364 }
365 await sleep(READY_INTERVAL_MS);
366 }
367
368 throw new Error(`Obsidian instance did not become ready for ${options.vaultName}. Last error: ${lastError}`);
369}
370
371export async function trustVaultAndVerifyQuickAdd(options) {
372 await execObsidian(options, [

Callers 2

ensureObsidianInstanceFunction · 0.90
mainFunction · 0.85

Calls 3

execObsidianFunction · 0.85
sleepFunction · 0.70
resolveMethod · 0.45

Tested by

no test coverage detected