Skip to content

Commit

Permalink
fix: errors during updates and uninstallations when runtime or subpro…
Browse files Browse the repository at this point in the history
…cess is invalid (#787)
  • Loading branch information
d-gubert authored Jul 29, 2024
1 parent 52805ec commit 292d69f
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/server/AppManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,11 @@ export class AppManager {
// the App instance from the source.
const app = await this.getCompiler().toSandBox(this, descriptor, result);

undoSteps.push(() => this.getRuntime().stopRuntime(app.getDenoRuntime()));
undoSteps.push(() =>
this.getRuntime()
.stopRuntime(app.getDenoRuntime())
.catch(() => {}),
);

// Create a user for the app
try {
Expand Down Expand Up @@ -639,9 +643,12 @@ export class AppManager {
await this.removeAppUser(app);
await (this.bridges.getPersistenceBridge() as IInternalPersistenceBridge & PersistenceBridge).purge(app.getID());
await this.appMetadataStorage.remove(app.getID());
await this.appSourceStorage.remove(app.getStorageItem()).catch();
await this.appSourceStorage.remove(app.getStorageItem()).catch(() => {});

await this.getRuntime().stopRuntime(app.getDenoRuntime());
// Errors here don't really prevent the process from dying, so we don't really need to do anything on the catch
await this.getRuntime()
.stopRuntime(app.getDenoRuntime())
.catch(() => {});

this.apps.delete(app.getID());
}
Expand Down Expand Up @@ -691,7 +698,10 @@ export class AppManager {
descriptor.signature = await this.signatureManager.signApp(descriptor);
const stored = await this.appMetadataStorage.update(descriptor);

await this.getRuntime().stopRuntime(this.apps.get(old.id).getDenoRuntime());
// Errors here don't really prevent the process from dying, so we don't really need to do anything on the catch
await this.getRuntime()
.stopRuntime(this.apps.get(old.id).getDenoRuntime())
.catch(() => {});

const app = await this.getCompiler().toSandBox(this, descriptor, result);

Expand Down Expand Up @@ -737,7 +747,10 @@ export class AppManager {
if (appPackageOrInstance instanceof Buffer) {
const parseResult = await this.getParser().unpackageApp(appPackageOrInstance);

await this.getRuntime().stopRuntime(this.apps.get(stored.id).getDenoRuntime());
// Errors here don't really prevent the process from dying, so we don't really need to do anything on the catch
await this.getRuntime()
.stopRuntime(this.apps.get(stored.id).getDenoRuntime())
.catch(() => {});

return this.getCompiler().toSandBox(this, stored, parseResult);
}
Expand Down

0 comments on commit 292d69f

Please sign in to comment.