fix: sometimes plugins were not restarted after an update
Massimo Melina committed
Oct 24, 2025 at 00:58 UTC
8975ee742de9e9259fef524720658f7c58a85206
1 file changed
+5
-3
src/github.ts
+5
-3
@@ -2,7 +2,8 @@
2
3
import events from './events'
4
import {
5
- httpString, httpStream, unzip, AsapStream, debounceAsync, asyncGeneratorToArray, retry, popKey, onlyTruthy, HOUR, DAY
5
+ httpString, httpStream, unzip, AsapStream, debounceAsync, asyncGeneratorToArray, retry, popKey, onlyTruthy, waitFor,
6
+ HOUR, DAY
7
} from './misc'
8
import {
9
DISABLING_SUFFIX, enablePlugin, findPluginByRepo, getInactivePlugins, getPluginInfo, isPluginRunning, mapPlugins,
@@ -136,8 +137,9 @@ export async function downloadPlugin(repo: Repo, { branch='', overwrite=false }=
137
await rename(tempInstallPath, installPath)
138
.catch(e => { throw e.code !== 'ENOENT' ? e : new ApiError(HTTP_NOT_ACCEPTABLE, "missing main file") })
139
if (wasRunning)
139
- void startPlugin(folder) // don't wait, in case it fails to start. We still use startPlugin instead of enablePlugin, as it will take care of disabling other themes.
140
- .catch(() => {}) // it will possibly fail (with 'miss') because the plugin has probably not been loaded yet.
140
+ if (await waitFor(() => getPluginInfo(folder), { timeout: 10_000 }))
141
+ void startPlugin(folder) // don't wait, in case it fails to start. We still use startPlugin instead of enablePlugin, as it will take care of disabling other themes.
142
+ .catch(console.warn)
143
events.emit('pluginDownloaded', { id: folder, repo })
144
return folder
145
}