mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-09 09:26:14 -08:00
fix(playback): handle close-only player exits
This commit is contained in:
1 parent
24482c429e
commit
3bbb35ba30
2 files changed
+22
No files matched your search
@@ -15,6 +15,26 @@ function createMockChildProcess(): ChildProcess {
|
||||
}
|
||||
|
||||
describe('external player process teardown', () => {
|
||||
it('accepts close as confirmed termination after a spawn error', async () => {
|
||||
const child = createMockChildProcess();
|
||||
child.on('error', () => undefined);
|
||||
let settled = false;
|
||||
const exit = waitForExternalPlayerProcessExit(child).then(() => {
|
||||
settled = true;
|
||||
});
|
||||
|
||||
child.emit(
|
||||
'error',
|
||||
Object.assign(new Error('spawn failed'), { code: 'ENOENT' })
|
||||
);
|
||||
await Promise.resolve();
|
||||
expect(settled).toBe(false);
|
||||
|
||||
child.emit('close', -2, null);
|
||||
|
||||
await expect(exit).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('does not treat a process error as confirmed exit', async () => {
|
||||
const child = createMockChildProcess();
|
||||
child.on('error', () => undefined);
|
||||
|
||||
@@ -14,9 +14,11 @@ export function waitForExternalPlayerProcessExit(
|
||||
return new Promise((resolve) => {
|
||||
const complete = () => {
|
||||
child.off('exit', complete);
|
||||
child.off('close', complete);
|
||||
resolve();
|
||||
};
|
||||
child.once('exit', complete);
|
||||
child.once('close', complete);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user