Skip to content

Conversation

@dlech
Copy link
Member

@dlech dlech commented Jan 24, 2026

On slow machines, udev rules may not have finished processing by the time we try to open the USB device. This causes a SecurityError, so we add a retry loop to handle this case.

Closes: pybricks/support#2372

@dlech dlech force-pushed the usb-delay-for-udev branch from 814d85b to f91242c Compare January 24, 2026 22:45
@dlech
Copy link
Member Author

dlech commented Jan 24, 2026

@laurensvalk, does this fix the issue for you?

@dlech dlech force-pushed the usb-delay-for-udev branch from 9ea524e to 576d9c4 Compare January 24, 2026 23:14
dlech added 2 commits January 24, 2026 23:16
On slow machines, udev rules may not have finished processing by the time
we try to open the USB device. This causes a SecurityError, so we add a
retry loop to handle this case.

Closes: pybricks/support#2372
Add a step to upload the build artifact after building the project.

This will make it easy for people to test it without having to build it
themselves.
@dlech dlech force-pushed the usb-delay-for-udev branch from 576d9c4 to 532852d Compare January 24, 2026 23:16
Comment on lines +32 to +41
- name: Set env to labs
run: |
echo "REACT_APP_NAME=Pybricks Labs" >> $GITHUB_ENV
echo "REACT_APP_SUFFIX=-labs" >> $GITHUB_ENV
echo "REACT_APP_VERSION=$GITHUB_SHA" >> $GITHUB_ENV
- run: yarn build
- uses: actions/upload-artifact@v6
with:
name: pybricks-labs
path: build
Copy link
Member

@laurensvalk laurensvalk Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this something we would occasionally add for particular PRs that need testing? (Otherwise how do we handle more than one PR?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't automatically publish anywhere. It it just uploads the artifact to GitHub. One could download it and run it locally with serve.py to test a PR without having to build it themselves. Or we can throw it on labs.pybricks.com if we want wider testing.

@laurensvalk
Copy link
Member

@laurensvalk, does this fix the issue for you?

Yes. Generally after the first 100ms as to be expected:

Retrying USB device open (1/5) after SecurityError on Linux

continue;
}

// TODO: show error message to user here
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make a issue/task for TODOs like these?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want one issue per error message or one for all of them? I don't remember if we have an issue for this in general or not.

Fix a race condition where a response to a USB command could be missed
if it arrives before the USB transferOut() call returns. This is done
by using a channel to buffer incoming responses.

Fixes: pybricks/support#2467
@dlech dlech enabled auto-merge (rebase) January 25, 2026 20:26
@dlech dlech merged commit 457fa8b into master Jan 25, 2026
2 checks passed
@dlech dlech deleted the usb-delay-for-udev branch January 25, 2026 20:30
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.

[Bug] USB connection does not re-establish when plugging back in

3 participants