Skip to content

Commit

Permalink
Make sure cache is up to date since we don't control the serializer d…
Browse files Browse the repository at this point in the history
…irectly
  • Loading branch information
sourishkrout committed Feb 7, 2025
1 parent e782e5e commit 29d8529
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/extension/executors/runner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ export const resolveProgramOptionsDagger: IResolveRunProgram = async ({
throw new Error('Cannot resolve notebook without cache entry')
}

const cachedNotebook = kernel.getParserCache(cacheId)
const cachedNotebook = await kernel.getParserCache(cacheId, exec.cell)
const notebookResolver = await runner.createNotebook(cachedNotebook)
const daggerShellScript = await notebookResolver.resolveDaggerNotebook(exec.cell.index)

Expand Down
17 changes: 15 additions & 2 deletions src/extension/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1284,8 +1284,21 @@ export class Kernel implements Disposable {
return this.serializer?.getNotebookDataCache(cacheId)
}

public getParserCache(cacheId: string): Serializer.Notebook | undefined {
return this.serializer?.getParserCache(cacheId)
public async getParserCache(
cacheId: string,
cell: NotebookCell,
): Promise<Serializer.Notebook | undefined> {
// ensure the serializer is caught up
for (let i = 0; i < 20; i++) {
const cellText = cell.document.getText()
const notebook = this.serializer?.getParserCache(cacheId)
if (notebook && notebook.cells[cell.index].value === cellText) {
return notebook
}
await new Promise((resolve) => setTimeout(resolve, 100))
}

return undefined
}

public async getReporterPayload(
Expand Down

0 comments on commit 29d8529

Please sign in to comment.