Fix nested worker randomly shutting off in Firefox (closes #435)

This commit is contained in:
Vanilagy
2026-07-18 14:44:57 +02:00
parent bfbd90e1d8
commit 0554696505
5 changed files with 17 additions and 0 deletions
@@ -192,3 +192,7 @@ if (parentPort) {
} else {
self.addEventListener('message', event => onMessage(event.data as { id: number; command: WorkerCommand }));
}
// Prevents the worker for being randomly closed by Firefox
// https://github.com/Vanilagy/mediabunny/issues/435
setInterval(() => {}, 1000);
+4
View File
@@ -304,3 +304,7 @@ if (parentPort) {
} else {
self.addEventListener('message', event => onMessage(event.data as { id: number; command: WorkerCommand }));
}
// Prevents the worker for being randomly closed by Firefox
// https://github.com/Vanilagy/mediabunny/issues/435
setInterval(() => {}, 1000);
+1
View File
@@ -46,6 +46,7 @@ export const unrefWorker = async () => {
if (worker) {
if (worker.unref) {
worker.unref(); // If we don't do this, then the Node process never terminates by itself
// Keep the worker around tho
} else if (typeof window === 'undefined') {
// Non-browser environment without unref - terminate instead
worker.terminate();
@@ -192,3 +192,7 @@ if (parentPort) {
} else {
self.addEventListener('message', event => onMessage(event.data as { id: number; command: WorkerCommand }));
}
// Prevents the worker for being randomly closed by Firefox
// https://github.com/Vanilagy/mediabunny/issues/435
setInterval(() => {}, 1000);
@@ -219,3 +219,7 @@ if (parentPort) {
} else {
self.addEventListener('message', event => onMessage(event.data as { id: number; command: WorkerCommand }));
}
// Prevents the worker for being randomly closed by Firefox
// https://github.com/Vanilagy/mediabunny/issues/435
setInterval(() => {}, 1000);