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

Fix #32, Replace https get with undici client.stream in download.mts #47

Merged
merged 4 commits into from
Aug 23, 2024

Conversation

mattmyne
Copy link
Contributor

Replacing https get with client.stream from the undici library improves performance and fixes stalled downloads on some systems.
Only updates src/utils/download.mts, though replacement in all files could be done if required in the future.

@will-v-pi
Copy link
Collaborator

Thanks for this - just adding a .vsix to this PR, and then I'll go test it on all my systems to check there are no regressions
raspberry-pi-pico-0.15.1.zip

@will-v-pi
Copy link
Collaborator

Couple of bug fixes in main which I've merged in, and I fixed some error handling when it downloads the toolchain. Tested on MacOS, RPiOS, and my Windows 11 and seems to work great - @mattmyne could you double check the latest version still fixes the problem for you, and then I'll merge this in? You can download the .vsix from https://github.com/raspberrypi/pico-vscode/actions/runs/10526534058

@mattmyne
Copy link
Contributor Author

This works for me. Removed everything (extension, .pico-sdk and temp files) and installed this .vsix. Selected a New Project from Example and everything downloaded and installed in <5 minutes.

Almost - there were a couple of issues but neither of them are related to this issue/PR. The first toolkit download attempt actually failed but the logs show this was a git-related rather than plain download issues. Repeated "fetch-pack: unexpected disconnect while reading sideband packet" git clone errors. Without changing anything I just tried again and it all worked so I'm putting it down to flaky git cloning, but I've included the whole error list if it helps for future issues.

The second issue is that when opening the newly-created project file, I now get:
"c:\Users\drmat\picow_blink/build/compile_commands.json" could not be parsed. 'includePath' from c_cpp_properties.json in folder 'PICOW_BLINK' will be used instead.
...but the #include "pico/cyw43_arch.h" can't be found (both highlighted with red squiggle in vscode and compile itself fails for the same reason). Oddly #include "pico/stdlib.h" can be found though, so it's not that is can't find pico/.
I tried a second time, including restarting vscode, but with the same include not found error. I'm guessing this might be related to changes made since the 0.15.1 release? I can open a new issue if you like.

Anyway - this PR does fix the download issue I had, thanks.

@mattmyne
Copy link
Contributor Author

As above, here's the git clone related error message:

[Extension Host] Error: Command failed: cd "C:/Users/drmat/.pico-sdk/sdk/2.0.0" && "C:\Program Files\Git\cmd\git.EXE" submodule update --init
Submodule 'lib/btstack' (https://github.com/bluekitchen/btstack.git) registered for path 'lib/btstack'
Submodule 'lib/cyw43-driver' (https://github.com/georgerobotics/cyw43-driver.git) registered for path 'lib/cyw43-driver'
Submodule 'lib/lwip' (https://github.com/lwip-tcpip/lwip.git) registered for path 'lib/lwip'
Submodule 'lib/mbedtls' (https://github.com/Mbed-TLS/mbedtls.git) registered for path 'lib/mbedtls'
Submodule 'tinyusb' (https://github.com/hathach/tinyusb.git) registered for path 'lib/tinyusb'
Cloning into 'C:/Users/drmat/.pico-sdk/sdk/2.0.0/lib/btstack'...
error: RPC failed; curl 18 HTTP/2 stream 5 was reset
error: 1503 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output
fatal: clone of 'https://github.com/bluekitchen/btstack.git' into submodule path 'C:/Users/drmat/.pico-sdk/sdk/2.0.0/lib/btstack' failed
Failed to clone 'lib/btstack'. Retry scheduled
Cloning into 'C:/Users/drmat/.pico-sdk/sdk/2.0.0/lib/cyw43-driver'...
Cloning into 'C:/Users/drmat/.pico-sdk/sdk/2.0.0/lib/lwip'...
Cloning into 'C:/Users/drmat/.pico-sdk/sdk/2.0.0/lib/mbedtls'...
error: RPC failed; curl 18 HTTP/2 stream 5 was reset
error: 6234 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output
fatal: clone of 'https://github.com/Mbed-TLS/mbedtls.git' into submodule path 'C:/Users/drmat/.pico-sdk/sdk/2.0.0/lib/mbedtls' failed
Failed to clone 'lib/mbedtls'. Retry scheduled
Cloning into 'C:/Users/drmat/.pico-sdk/sdk/2.0.0/lib/tinyusb'...
error: RPC failed; curl 18 HTTP/2 stream 5 was reset
error: 6287 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output
fatal: clone of 'https://github.com/hathach/tinyusb.git' into submodule path 'C:/Users/drmat/.pico-sdk/sdk/2.0.0/lib/tinyusb' failed
Failed to clone 'lib/tinyusb'. Retry scheduled
Cloning into 'C:/Users/drmat/.pico-sdk/sdk/2.0.0/lib/btstack'...
error: RPC failed; curl 18 HTTP/2 stream 5 was reset
error: 3541 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output
fatal: clone of 'https://github.com/bluekitchen/btstack.git' into submodule path 'C:/Users/drmat/.pico-sdk/sdk/2.0.0/lib/btstack' failed
Failed to clone 'lib/btstack' a second time, aborting

	at genericNodeError (node:internal/errors:984:15)
	at wrappedFn (node:internal/errors:538:14)
	at ChildProcess.exithandler (node:child_process:423:12)
	at ChildProcess.emit (node:events:519:28)
	at maybeClose (node:internal/child_process:1105:16)
	at ChildProcess._handle.onexit (node:internal/child_process:305:5)
y @ console.ts:137
log.ts:439   ERR [Extension Host] [�[31mERROR�[0m] [NewProjectPanel] Failed to download and install toolchain and SDK.

@will-v-pi
Copy link
Collaborator

Repeated "fetch-pack: unexpected disconnect while reading sideband packet" git clone errors

I've seen these issues sometimes when I have a dodgy Wi-fi connection, so I think they're unrelated to the extension, just an issue with git cloning on with unreliable internet

@will-v-pi
Copy link
Collaborator

The second issue is that when opening the newly-created project file, I now get:
"c:\Users\drmat\picow_blink/build/compile_commands.json" could not be parsed. 'includePath' from c_cpp_properties.json in folder 'PICOW_BLINK' will be used instead.
...but the #include "pico/cyw43_arch.h" can't be found (both highlighted with red squiggle in vscode and compile itself fails for the same reason). Oddly #include "pico/stdlib.h" can be found though, so it's not that is can't find pico/.
I tried a second time, including restarting vscode, but with the same include not found error. I'm guessing this might be related to changes made since the 0.15.1 release? I can open a new issue if you like.

The "c:\Users\drmat\picow_blink/build/compile_commands.json" could not be parsed error may be shown when you first create a project depending on whether CMake has run in time (which generates that file). It should go away if you close and re-open the window.

As for pico/cyw43_arch.h - double check you've selected a pico_w board rather than a pico board? If you've definitely got a pico_w board selected then open a new issue for that, as it should work

@will-v-pi
Copy link
Collaborator

And thanks very much for your work on this PR! I'll merge it now

@will-v-pi will-v-pi merged commit 918733b into raspberrypi:main Aug 23, 2024
1 check passed
@mattmyne
Copy link
Contributor Author

Just to follow-up on the missing include, it was related to that first git clone error. The SDK download/cloning must have been interrupted before the cyw43_arch related files had been created, but since the SDK folder wasn't empty the second attempt skipped it assuming it was installed ok.

Deleting the SDK folder and re-running the New Project From Example command cloned everything correctly and the include error has gone. I did this using the above .vsix install, so no issues there.

@mattmyne mattmyne deleted the download-use-undici branch August 23, 2024 18:59
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