Avoid plug loading race condition
This commit is contained in:
parent
9921d72b96
commit
0475c4c40e
@ -23,6 +23,7 @@ export class KVPrimitivesManifestCache<T> implements ManifestCache<T> {
|
||||
const manifest = plug.sandbox.manifest!;
|
||||
await this.kv.batchSet([{
|
||||
key: [this.manifestPrefix, plug.name],
|
||||
// Deliverately removing the assets from the manifest to preserve space, will be re-added upon load of actual worker
|
||||
value: { manifest: { ...manifest, assets: undefined }, hash },
|
||||
}]);
|
||||
return manifest;
|
||||
@ -43,7 +44,11 @@ export class InMemoryManifestCache<T> implements ManifestCache<T> {
|
||||
}
|
||||
await plug.sandbox.init();
|
||||
const manifest = plug.sandbox.manifest!;
|
||||
this.cache.set(plug.name!, { manifest, hash });
|
||||
// Deliverately removing the assets from the manifest to preserve space, will be re-added upon load of actual worker
|
||||
this.cache.set(plug.name!, {
|
||||
manifest: { ...manifest, assets: undefined },
|
||||
hash,
|
||||
});
|
||||
return manifest;
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +32,9 @@ export class Sandbox<HookT> {
|
||||
init(): Promise<void> {
|
||||
console.log("Booting up worker for", this.plug.name);
|
||||
if (this.worker) {
|
||||
// Should not happen
|
||||
console.warn("Double init of sandbox");
|
||||
// Race condition
|
||||
console.warn("Double init of sandbox, ignoring");
|
||||
return Promise.resolve();
|
||||
}
|
||||
this.worker = new Worker(this.plug.workerUrl, {
|
||||
...this.workerOptions,
|
||||
|
Loading…
Reference in New Issue
Block a user