Skip to content

Commit 6f6fec5

Browse files
author
Tanmay Sharma
committed
fix(realtime): updated the worker clearance in the _startWorkerHeartBeat function
Previously, the worker error handler in _startWorkerHeartbeat() directly calledworkerRef.terminate() without clearing the workerRef reference. This caused amemory leak on worker errors because on reconnection, the guard check for workerRef would prevent creating a new worker, leaving the connection withouta heartbeat mechanism.Now uses the centralized _terminateWorker() method which both terminates theworker and clears the reference, ensuring proper cleanup and allowing newworkers to be created on reconnection.This complements the fix in _teardownConnection() to fully prevent workermemory leaks across all disconnect/error scenarios.
1 parent 0949fc0 commit 6f6fec5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/core/realtime-js/src/RealtimeClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ export default class RealtimeClient {
699699
this.workerRef = new Worker(objectUrl)
700700
this.workerRef.onerror = (error) => {
701701
this.log('worker', 'worker error', (error as ErrorEvent).message)
702-
this.workerRef!.terminate()
702+
this._terminateWorker()
703703
}
704704
this.workerRef.onmessage = (event) => {
705705
if (event.data.event === 'keepAlive') {

0 commit comments

Comments
 (0)