mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-07 16:03:21 +00:00
fix: fix custom TS Monaco worker not reloading on file uri change (#8130)
This commit is contained in:
@@ -1913,12 +1913,11 @@
|
||||
})
|
||||
|
||||
let isTsWorkerInitialized = resource(
|
||||
[() => lang, () => initialized, () => filePath],
|
||||
[() => lang, () => initialized],
|
||||
async () => {
|
||||
if (lang !== 'typescript' || !initialized) return false
|
||||
console.log('[Editor.isTsWorkerInitialized] Waiting for TS Worker...')
|
||||
await waitForWorkerInitialization(filePath)
|
||||
console.log('[Editor.isTsWorkerInitialized] TS Worker initialized successfully')
|
||||
// Use the stable model URI (computed once at mount), not filePath which changes on rename
|
||||
await waitForWorkerInitialization(uri)
|
||||
return true
|
||||
}
|
||||
)
|
||||
@@ -1929,7 +1928,7 @@
|
||||
if (lang !== 'typescript' || !isTsWorkerInitialized.current) return
|
||||
if (!preparedAssetsSqlQueries || preparedAssetsSqlQueries.length === 0) {
|
||||
// Clear SQL queries if none exist
|
||||
updateSqlQueriesInWorker(filePath, [])
|
||||
updateSqlQueriesInWorker(uri, [])
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1937,14 +1936,13 @@
|
||||
// The worker will inject type parameters into the code that TypeScript analyzes
|
||||
|
||||
// Worker async function call freezes if we pass a Proxy, $state.snapshot() is very important here
|
||||
updateSqlQueriesInWorker(filePath, $state.snapshot(preparedAssetsSqlQueries))
|
||||
updateSqlQueriesInWorker(uri, $state.snapshot(preparedAssetsSqlQueries))
|
||||
}, 250)
|
||||
|
||||
watch(
|
||||
[
|
||||
() => preparedAssetsSqlQueries,
|
||||
() => lang,
|
||||
() => filePath,
|
||||
() => isTsWorkerInitialized.current
|
||||
],
|
||||
() => {
|
||||
|
||||
@@ -36,13 +36,12 @@ async function getWorkerClient(): Promise<(...uris: Uri[]) => Promise<ExtendedTy
|
||||
}
|
||||
}
|
||||
|
||||
export async function waitForWorkerInitialization(fileUri: string): Promise<true> {
|
||||
export async function waitForWorkerInitialization(modelUri: string): Promise<true> {
|
||||
const WORKER_INIT_TIMEOUT = 10000
|
||||
const MAX_RETRIES = 10
|
||||
const RETRY_DELAY = 300
|
||||
|
||||
if (!fileUri.endsWith('.ts')) fileUri += '.ts'
|
||||
const uri = Uri.parse(fileUri)
|
||||
const uri = Uri.parse(modelUri)
|
||||
|
||||
const startTime = Date.now()
|
||||
|
||||
@@ -84,12 +83,11 @@ export async function waitForWorkerInitialization(fileUri: string): Promise<true
|
||||
* @returns Promise that resolves when the update is complete
|
||||
*/
|
||||
export async function updateSqlQueriesInWorker(
|
||||
fileUri: string,
|
||||
modelUri: string,
|
||||
queries: InferAssetsSqlQueryDetails[]
|
||||
): Promise<void> {
|
||||
try {
|
||||
if (!fileUri.endsWith('.ts')) fileUri += '.ts'
|
||||
const uri = Uri.parse(fileUri)
|
||||
const uri = Uri.parse(modelUri)
|
||||
const uriString = uri.toString()
|
||||
|
||||
const workerClient = await getWorkerClient()
|
||||
|
||||
Reference in New Issue
Block a user