Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webusb: when connecting, send a few commands to flush commands #5843

Merged
merged 5 commits into from
Aug 22, 2024

Conversation

jwunderl
Copy link
Member

@jwunderl jwunderl commented Aug 21, 2024

On my machine with a teams call & full server (watched pxt build / pxt serve) I was able to repro the 5 -> 131 almost 100% of the time when refreshing the same page (turns out having an old device helped a bit!). After poking at it for a bit, this fix of moving "command flushing" up / repeating it a few times to ensure it's cleared seems to have fixed that 100% on my machine in that scenario. I don't have as good of repro cases for the other issues but trying to get repros on the other scenarios now.

(test program i was using, modified from a previous one to be more spammy https://makecode.microbit.org/_5j14oYbeTcCC)

I believe this should actually cover the cases that the more comprehensive suggestion in #5530 handles; our typical tactic for errors in operations is 'throw up hands and reconnect when things misbehave', so clearing through this does largely the same without spreading the logic throughout the app (and if not, first step would be to add reconnect attempts in those scenarios.)

@jwunderl jwunderl requested a review from a team August 21, 2024 23:19
Copy link
Contributor

@thsparks thsparks left a comment

Choose a reason for hiding this comment

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

One nit, otherwise LGTM!

@@ -312,15 +312,21 @@ class DAPWrapper implements pxt.packetio.PacketIOWrapper {

await this.io.reconnectAsync()

// before calling into dapjs, push through a commands to make sure the responses
// to commands from previous sessions (if any) are flushed
for (let i = 0; i < 5; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Was 5 just arbitrary? If so, a quick update to the comment above might be helpful indicating that.

@jwunderl jwunderl merged commit 7222e3c into master Aug 22, 2024
6 checks passed
@jwunderl jwunderl deleted the dev/jwunderl/clear-buff branch August 22, 2024 00:13
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.

2 participants