fix: prevent unnecessary updates on socket events
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test (20.x) (push) Has been cancelled
test / test (22.x) (push) Has been cancelled
test / api-test (22.x) (push) Has been cancelled

Updated the `bindSocketEvents` method to check the `original_client_socket_id` before posting updates for 'cache.updated' and 'item.renamed' events. This prevents unnecessary updates when the event originates from the same client socket.
This commit is contained in:
jelveh
2025-09-28 14:35:45 -07:00
parent f1fd372933
commit ef74a1a660
+16 -2
View File
@@ -113,8 +113,22 @@ export class PuterJSFileSystemModule extends AdvancedBase {
}
bindSocketEvents() {
this.socket.on('cache.updated', (item) => {
this.postUpdate();
this.socket.on('cache.updated', (msg) => {
// check original_client_socket_id and if it matches this.socket.id, don't post update
if (msg.original_client_socket_id === this.socket.id) {
return;
}else{
this.postUpdate();
}
});
this.socket.on('item.renamed', (item) => {
// check original_client_socket_id and if it matches this.socket.id, don't post update
if (item.original_client_socket_id === this.socket.id) {
return;
}else{
this.postUpdate();
}
});
this.socket.on('connect', () => {