mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
fix: memory leak in render threads
This commit is contained in:
1 parent
900c290e75
commit
f9e0584f00
1 file changed
+12
-8
@@ -19,18 +19,22 @@ function manageQueue() {
|
||||
|
||||
function cleanup() {
|
||||
workers.push(worker);
|
||||
worker.off('message', handleMessage);
|
||||
worker.off('error', handleError);
|
||||
manageQueue();
|
||||
}
|
||||
function handleMessage(png: Uint8Array) {
|
||||
cleanup();
|
||||
resolve(Buffer.from(png));
|
||||
}
|
||||
function handleError(error: Error) {
|
||||
cleanup();
|
||||
throw error;
|
||||
}
|
||||
|
||||
worker.postMessage(svg);
|
||||
worker.on('message', (png: Uint8Array) => {
|
||||
cleanup();
|
||||
resolve(Buffer.from(png));
|
||||
});
|
||||
worker.on('error', (error) => {
|
||||
cleanup();
|
||||
throw error;
|
||||
});
|
||||
worker.on('message', handleMessage);
|
||||
worker.on('error', handleError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user