fix(plugins): unload late-loading plugins before quit teardown

- unloadAll waits for an in-progress load so plugins still activating get deactivated too
- One 2 s budget covers the load wait and all deactivates
- Quit cleanup awaits plugin unload before any other teardown
- Force-quit timer now allows the plugin budget plus 2 s
This commit is contained in:
sudacode committed 2026-10-27 00:33:29 -07:00
1 parent 7a526531d7
commit 4bb85f19bc
6 files changed
+92 -24

No files matched your search

@@ -279,6 +279,30 @@ test('events follow a replacement mpv client', async () => {
}
});
test('unload waits for an in-progress load so late plugins are unloaded too', async () => {
const h = createHarness({ late: enabled() });
const client = createFakeMpvClient();
try {
writePlugin(h.root, 'late', {
'plugin.json': JSON.stringify({ main: 'main.cjs' }),
'main.cjs': `exports.activate = (ctx) => {
ctx.mpv.on('pause-change', () => ctx.notify('still listening'));
return () => ctx.notify('deactivated');
};`,
});
h.host.attachMpvClient(client);
// The plugin is still reading its manifest when unload starts.
void h.host.loadAll();
await h.host.unloadAll();
client.emit('pause-change', { paused: true });
assert.deepEqual(h.notifications, ['deactivated']);
} finally {
h.cleanup();
}
});
test('runAction waits for a load that is still in progress', async () => {
const h = createHarness({ slow: enabled() });
try {