windmill-labs/windmill · warning

[SqlTypeService] Worker initialization failed for ${uri.toSt

Error message

[SqlTypeService] Worker initialization failed for ${uri.toString()} after ${MAX_RETRIES} retries.

What it means

waitForWorkerInitialization retries up to MAX_RETRIES (10) times for the Monaco TypeScript worker to expose the custom updateSqlQueries method. If every attempt throws and the retry loop is exhausted (without the wall-clock timeout firing first), it throws this error. It means the customized TypeScript worker never became available for the given file URI.

Source

Thrown at frontend/src/lib/components/sqlTypeService.ts:70

			return true
		} catch (error) {
			if (retries >= 5) {
				console.warn(
					`[SqlTypeService] Worker not ready yet for ${uri.toString()}, retrying... (${
						retries + 1
					}/${MAX_RETRIES})`
				)
			}
			if (Date.now() - startTime > WORKER_INIT_TIMEOUT) {
				throw new Error(
					`[SqlTypeService] Worker initialization timeout for ${uri.toString()}. Custom method not found after ${WORKER_INIT_TIMEOUT}ms`
				)
			}
			await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY))
		}
	}

	throw new Error(
		`[SqlTypeService] Worker initialization failed for ${uri.toString()} after ${MAX_RETRIES} retries.`
	)
}

/**
 * Update SQL query type information in the TypeScript worker
 *
 * This function sends the parsed SQL query details to the custom TypeScript worker,
 * which will then inject type parameters into the code that TypeScript analyzes.
 *
 * @param fileUri - Monaco URI or string path of the file being edited
 * @param queries - Array of SQL query details from the WASM parser
 * @returns Promise that resolves when the update is complete
 */
export async function updateSqlQueriesInWorker(
	modelUri: string,
	queries: InferAssetsSqlQueryDetails[]
): Promise<void> {

View on GitHub (pinned to e474e8803c)

Solutions

  1. Fix the underlying worker error logged by getWorkerClient ('Failed to get TypeScript worker client') — the retry exhaustion is a symptom.
  2. Confirm the custom worker build (with updateSqlQueries) is shipped and reachable; re-check bundler config for monaco workers.
  3. Add a graceful fallback so SQL type annotation failure does not block the editor.
  4. Bump MAX_RETRIES only if worker startup is legitimately slow; otherwise investigate why every attempt fails.

Example fix

// before
await waitForWorkerInitialization(uri) // throws after 10 retries
// after
const ready = await waitForWorkerInitialization(uri).catch(() => false)
if (ready) {
  await updateSqlQueriesInWorker(uri, queries)
} // else: skip SQL type enrichment, editor remains usable
Defensive patterns

Strategy: try-catch

Validate before calling

const client = await getWorkerClient().catch(() => null)
if (!client) {
  console.warn('Monaco TS worker unavailable — skipping SQL type enrichment')
}

Type guard

function isExtendedWorker(w: unknown): w is ExtendedTypeScriptWorker {
  return !!w && typeof (w as any).updateSqlQueries === 'function'
}

Try / catch

const ok = await waitForWorkerInitialization(modelUri).catch(() => false)
if (!ok) {
  // skip updateSqlQueriesInWorker; editor still functions without SQL types
}

Prevention

When it happens

Trigger: All 10 retries (300ms apart) fail to obtain a worker client or the custom method for the model URI — the loop completes without returning true.

Common situations: Worker bundle broken by a monaco-vscode upgrade; worker client factory permanently failing (network/CSP issues in dev); calling the service in environments where the Monaco TypeScript worker is not configured at all.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/8dbe5070fa874021. Report an issue: GitHub.