Skip to content

Commit

Permalink
Add cache busting to worker URL.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Jun 14, 2024
1 parent c6f9499 commit bdef6fe
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/runner.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { WorkerToHostMessage } from './proto';

const workerURL = `app.worker.js?hash=${globalThis.GIT_COMMIT.substr(0, 8)}`;

export class PythonError extends Error {}

export class ToolRunner {
#worker = new Worker('app.worker.js', { type: 'module' });
#worker = new Worker(workerURL, { type: 'module' });
#packages: null | string[] = null;

private initializeWorker(packages: string[]): Worker {
if (JSON.stringify(this.#packages) !== JSON.stringify(packages)) {
if (this.#worker !== null && this.#packages !== null) {
// Terminate and re-initialize if the set of packages has changed.
this.#worker.terminate();
this.#worker = new Worker('app.worker.js', { type: 'module' });
this.#worker = new Worker(workerURL, { type: 'module' });
}
this.#worker.postMessage({ type: 'loadPackages', pkgs: packages });
this.#packages = packages;
Expand Down

0 comments on commit bdef6fe

Please sign in to comment.