fix: app subprocess restart not running onEnable lifecycle (#34172)

pull/34000/head^2
Douglas Gubert 1 year ago committed by GitHub
parent 3d41ae2455
commit eb794b7fd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      .changeset/chilled-seas-refuse.md
  2. 8
      packages/apps-engine/src/server/AppManager.ts
  3. 8
      packages/apps-engine/src/server/runtime/deno/AppsEngineDenoRuntime.ts

@ -0,0 +1,5 @@
---
'@rocket.chat/apps-engine': patch
---
Fixes the subprocess restarting routine failing to correctly restart apps in some cases

@ -1035,6 +1035,10 @@ export class AppManager {
result = false;
await app.setStatus(status, silenceStatus);
// If some error has happened in initialization, like license or installations invalidation
// we need to store this on the DB regardless of what the parameter requests
saveToDb = true;
}
if (saveToDb) {
@ -1113,6 +1117,10 @@ export class AppManager {
}
console.error(e);
// If some error has happened during enabling, like license or installations invalidation
// we need to store this on the DB regardless of what the parameter requests
saveToDb = true;
}
if (enable) {

@ -9,14 +9,14 @@ import { LivenessManager } from './LivenessManager';
import { ProcessMessenger } from './ProcessMessenger';
import { bundleLegacyApp } from './bundler';
import { decoder } from './codec';
import { AppStatus } from '../../../definition/AppStatus';
import { AppStatus, AppStatusUtils } from '../../../definition/AppStatus';
import type { AppMethod } from '../../../definition/metadata';
import type { AppManager } from '../../AppManager';
import type { AppBridges } from '../../bridges';
import type { IParseAppPackageResult } from '../../compiler';
import { AppConsole, type ILoggerStorageEntry } from '../../logging';
import type { AppAccessorManager, AppApiManager } from '../../managers';
import type { AppLogStorage, IAppStorageItem } from '../../storage';
import { AppMethod } from '../../../definition/metadata';
const baseDebug = debugFactory('appsEngine:runtime:deno');
@ -287,6 +287,10 @@ export class DenoRuntimeSubprocessController extends EventEmitter {
await this.sendRequest({ method: 'app:initialize' });
await this.sendRequest({ method: 'app:setStatus', params: [this.storageItem.status] });
if (AppStatusUtils.isEnabled(this.storageItem.status)) {
await this.sendRequest({ method: 'app:onEnable' });
}
this.state = 'ready';
logger.info('Successfully restarted app subprocess');

Loading…
Cancel
Save