export async function waitForHttp(url, options = {}) { const timeoutMs = options.timeoutMs || 60000; const intervalMs = options.intervalMs || 500; const start = Date.now(); let lastError; while (Date.now() - start < timeoutMs) { try { const response = await fetch(url, { cache: 'no-store' }); if (response.ok) return response; lastError = new Error(`HTTP ${response.status}`); } catch (error) { lastError = error; } await new Promise((resolve) => setTimeout(resolve, intervalMs)); } throw new Error(`Timed out waiting for ${url}: ${lastError?.message || 'no response'}`); }