Page MenuHomePhabricator

Duplicate socket event listeners can be registered in Home component, leading to repeated state updates
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Open VideoCutTool and navigate to the home page.
  • Allow the page to re-render due to normal state changes (for example, socket updates or context updates).
  • Observe that socket event listeners (such as socket.on('update', ...)) are registered outside of a React useEffect hook.
  • When the corresponding socket event is emitted by the server, the handler may be invoked multiple times during a single session.

What happens?:

The Home component registers socket event listeners directly in the component body instead of within a React effect with cleanup.
As a result, multiple listeners can be attached over time, leading to repeated state updates and unnecessary re-renders when the same socket event is received.

What should have happened instead?:

Socket event listeners should be registered inside a React useEffect hook and cleaned up appropriately on unmount or dependency changes.
This ensures that each socket event is handled only once per component lifecycle and prevents duplicated UI updates during longer sessions.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

N/A (client-side issue observed in the current VideoCutTool frontend)

Other information (browser name/version, screenshots, etc.):

  • Frontend-only issue related to React component lifecycle management.
  • The behavior may be subtle and more noticeable during extended usage or when socket events are emitted multiple times.
  • Based on review of the current Home component implementation in the VideoCutTool repository.

Event Timeline

I prepared a fix that moves the socket.on('update') listener into a useEffect with cleanup to prevent duplicate registrations.
However, the Gerrit repository labs/tools/VideoCutTool appears to be read-only (project state does not permit write), so I’m unable to submit the patch.
Please advise on the preferred contribution path (GitHub PR or alternative repo).

Hi @Aklapper ,

I’ve opened a GitLab merge request that addresses this issue by moving the socket.on('update') listener into a useEffect hook with proper cleanup to avoid duplicate listener registrations and repeated state updates.

GitLab Merge Request: https://gitlab.wikimedia.org/cloudvps-repos/videocuttool/VideoCutTool/-/merge_requests/60

I’d appreciate your review and feedback. Please let me know if any changes are required — I’m happy to update the patch accordingly to help get this merged successfully.

Thanks.

@Kunal2512: Congratulations. No need to ping any individuals though, I am not a developer in this project.
The patch seems to include numerous unrelated changes though (empty lines, whitespace) that shouldn't be part of it?

Thanks for the note.
I’ll clean up the patch to remove the unrelated whitespace and formatting changes and keep the diff focused strictly on the socket listener fix. I’m working on this and will update the merge request shortly.

Hi
The changes for this task are in this merge request - MR-60

Please link the Phab task via a separate Bug: T00000 line like described in https://www.mediawiki.org/wiki/Gerrit/Commit_message_guidelines instead of that AI created commit message section. Thanks!

Hi, I’ve updated the commit message to follow the Gerrit guidelines and added the separate Bug: T416500 footer. Thanks

Hi, I’ve checked the GitLab Commits section of MR
It shows a single commit, and opening that commit displays the structured commit message including the separate Bug: T416500 footer.
I’ve attached a screenshot below showing this view.

Screenshot 2026-02-09 at 11.32.17 AM.png (1×2 px, 777 KB)

Your screenshot shows one commit within the merge request. See the "Overview" tab instead for the overall commit message.

Thanks for the clarification I’ve updated the merge request Overview description to align with the commit message

Screenshot 2026-02-09 at 5.14.32 PM.png (1×2 px, 805 KB)

Hi, I’ve addressed the previous feedback and already updated the merge request.
Please let me know if anything further needs to be adjusted.
Thanks.