Skip to content

Commit

Permalink
server: Fix bug where mixins are not invalidated after a plugin resta…
Browse files Browse the repository at this point in the history
…rt fails, and then later succeeds.
  • Loading branch information
koush committed Jun 26, 2024
1 parent 0d27045 commit ce5547e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 36 deletions.
56 changes: 28 additions & 28 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
"ip": "^2.0.1",
"level": "^8.0.1",
"lodash": "^4.17.21",
"nan": "^2.19.0",
"nan": "^2.20.0",
"node-dijkstra": "^2.5.0",
"node-forge": "^1.3.1",
"node-gyp": "^10.1.0",
"py": "npm:@bjia56/portable-python@^0.1.51",
"py": "npm:@bjia56/portable-python@^0.1.52",
"router": "^1.3.8",
"semver": "^7.6.2",
"sharp": "^0.33.4",
"source-map-support": "^0.5.21",
"tar": "^7.2.0",
"tar": "^7.4.0",
"tslib": "^2.6.3",
"typescript": "^5.4.5",
"typescript": "^5.5.2",
"whatwg-mimetype": "^4.0.0",
"ws": "^8.17.0"
"ws": "^8.17.1"
},
"devDependencies": {
"@types/adm-zip": "^0.5.5",
Expand All @@ -40,7 +40,7 @@
"@types/follow-redirects": "^1.14.4",
"@types/http-auth": "^4.1.4",
"@types/ip": "^1.1.3",
"@types/lodash": "^4.17.4",
"@types/lodash": "^4.17.5",
"@types/node-dijkstra": "^2.5.6",
"@types/node-forge": "^1.3.11",
"@types/semver": "^7.5.8",
Expand Down
3 changes: 1 addition & 2 deletions server/src/plugin/plugin-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ export class PluginHost {
}
this.ws = {};

const deviceIds = new Set<string>(Object.values(this.scrypted.pluginDevices).filter(d => d.pluginId === this.pluginId).map(d => d._id));
this.scrypted.invalidateMixins(deviceIds);
this.scrypted.invalidatePluginMixins(this.pluginId);

this.consoleServer.then(server => server.destroy());
}
Expand Down
6 changes: 6 additions & 0 deletions server/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ export class ScryptedRuntime extends PluginHttp<HttpPluginData> {
delete this.plugins[pluginId];
existing.kill();
}
this.invalidatePluginMixins(pluginId);
}

// should this be async?
Expand All @@ -483,6 +484,11 @@ export class ScryptedRuntime extends PluginHttp<HttpPluginData> {
return proxyPair;
}

invalidatePluginMixins(pluginId: string) {
const deviceIds = new Set<string>(Object.values(this.pluginDevices).filter(d => d.pluginId === pluginId).map(d => d._id));
this.invalidateMixins(deviceIds);
}

invalidateMixins(ids: Set<string>) {
const ret = new Set<string>();
const remaining = [...ids];
Expand Down

0 comments on commit ce5547e

Please sign in to comment.