Skip to content

Commit

Permalink
server: plugin reload/deletion race.
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Apr 20, 2024
1 parent a5a1959 commit 6eae1c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions server/src/plugin/plugin-host-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export class PluginHostAPI extends PluginAPIManagedListeners implements PluginAP
restartDebounced = debounce(async () => {
const plugin = await this.scrypted.datastore.tryGet(Plugin, this.pluginId);
const host = this.scrypted.plugins[this.pluginId];
if (!plugin) {
const logger = await this.getLogger(undefined);
logger.log('w', 'plugin restart was requested, but plugin was not found. restart cancelled.');
return;
}
if (host?.api !== this) {
const logger = await this.getLogger(undefined);
logger.log('w', 'plugin restart was requested, but a different instance was found. restart cancelled.');
Expand Down
2 changes: 1 addition & 1 deletion server/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ export class ScryptedRuntime extends PluginHttp<HttpPluginData> {
logger.log('w', `scheduled plugin restart cancelled, plugin no longer exists ${pluginHost.pluginId}`);
return;
}

const existing = this.plugins[pluginHost.pluginId];
if (existing !== pluginHost) {
logger.log('w', `scheduled plugin restart cancelled, plugin was restarted by user ${pluginHost.pluginId}`);
Expand Down

0 comments on commit 6eae1c7

Please sign in to comment.