Skip to content

Quality: Missing dependency in useEffect cleanup for usb.jsx#665

Open
tomaioo wants to merge 1 commit into
scratchfoundation:developfrom
tomaioo:improve/quality/missing-dependency-in-useeffect-cleanup-
Open

Quality: Missing dependency in useEffect cleanup for usb.jsx#665
tomaioo wants to merge 1 commit into
scratchfoundation:developfrom
tomaioo:improve/quality/missing-dependency-in-useeffect-cleanup-

Conversation

@tomaioo

@tomaioo tomaioo commented Jun 26, 2026

Copy link
Copy Markdown

Summary

Quality: Missing dependency in useEffect cleanup for usb.jsx

Problem

Severity: Medium | File: src/renderer/usb.jsx:L14

The useEffect hook in usb.jsx has a missing dependency: selectedDeviceId is used in the cleanup logic (inside the listener) but not included in the dependency array. This can lead to stale closure issues where the cleanup logic references an outdated value of selectedDeviceId.

Solution

Add selectedDeviceId to the dependency array of the useEffect hook, or use a functional update pattern to avoid the dependency issue.

Changes

  • src/renderer/usb.jsx (modified)

The useEffect hook in usb.jsx has a missing dependency: `selectedDeviceId` is used in the cleanup logic (inside the listener) but not included in the dependency array. This can lead to stale closure issues where the cleanup logic references an outdated value of `selectedDeviceId`.

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant