Repository navigation
fix(share): simplify ddev share provider scripts and show output in real-time - #8156
Conversation
|
Download the artifacts for this pull request:
See Testing a PR. |
|
Note: it's important to run No internet ngrok: Before (no error details): After: No internet cloudflared: Before (no error details): After: No internet localtunnel: Before (no error details): After (the same, but this is how localtunnel works, it doesn't output any errors here): My local problems with cloudflared (it's blocked on internet provider level): Before (no error details): After: My another local problem with cloudflared, when I try to connect to cloudflare network using Cloudflare WARP:
Before (no errors for failed incoming requests): After: Improvement in localtunnel: Before (no password info): After (now with a password): |
2f40bbe to
de7f3cd
Compare
|
TODO: test how it works on traditional Windows without the Internet. When a script reaches a timeout of 60 seconds, it must terminate not only the script process, but also the child process |
rfay
left a comment
There was a problem hiding this comment.
Looks to me like an excellent simplification and it's way better to show error output. Thanks!
| # Documentation: https://docs.ddev.com/en/stable/users/topics/sharing/ | ||
| # | ||
| # To customize: remove the '#ddev-generated' line above and edit as needed. | ||
| # To customize: remove the 'ddev-generated' line above and edit as needed. |
## The Issue When `ddev share --provider=cloudflared` failed, users saw only "Provider 'cloudflared' did not output a URL" with no error details. The actual error (e.g., "context deadline exceeded") was silently swallowed, forcing users to manually run the cloudflared command to diagnose the problem. Two bugs caused this: 1. `set -e` caused scripts to abort at `wait $PID` before reaching diagnostic output code 2. Stderr filtering suppressed non-structured error messages ## How This PR Solves The Issue Rewrites all three share provider scripts (cloudflared, ngrok, localtunnel) to follow the same simple pattern: - `cmd 2>&1 | while IFS= read -r line` replaces named pipes, temp files, background readers, and polling loops - All provider output is shown to the user in real-time via stderr - Only structured INFO lines are filtered (` INF ` for cloudflared, ` lvl=info ` for ngrok); errors always show - URL is extracted from output with provider-specific regex and sent to stdout for DDEV to capture - ngrok now uses `--log=stdout` and parses the URL from log output instead of polling the localhost:4040 API (removes curl/jq dep) Go-side changes (share.go): - Removed stderr pipe/buffer machinery; stderr goes directly to os.Stderr since scripts now handle output display - Removed verbose stdout branching (scripts show everything on stderr) - Added 60-second timeout for URL capture as a safety net - Provider exit code is now propagated to the ddev process Other improvements: - `PopulateShareProviders()` is called from `GetShareProviderScript()` so script updates take effect on `ddev share` without requiring `ddev restart` - localtunnel example fetches and displays the tunnel password - Added ddev-generated customization note to localtunnel example ## Manual Testing Instructions 1. Run `ddev share --provider=ngrok` - verify tunnel starts, URL is displayed, and non-info log output is visible 2. Run `ddev share --provider=cloudflared` - verify tunnel starts, URL is displayed, and non-info log output is visible 3. Test localtunnel: `cp .ddev/share-providers/localtunnel.sh.example .ddev/share-providers/localtunnel.sh && ddev share --provider=localtunnel` 4. Test without internet connectivity - verify error output is shown in real-time rather than silently swallowed 5. Run two `ddev share --provider=ngrok` for the same project - verify the second instance shows a clear error ## Automated Testing Overview No new automated tests. The share providers require external services (ngrok, cloudflared) that are not available in CI. Changes are tested manually. ## Release/Deployment Notes - ngrok share provider now requires ngrok to support `--log=stdout` flag (available in all current versions) - The localhost:4040 API polling approach for ngrok is removed - Share provider scripts will auto-update on next `ddev share` (via PopulateShareProviders) for projects with #ddev-generated scripts Co-Authored-By: Claude Opus 4.6 <[email protected]>
de7f3cd to
a11d4a0
Compare
I retested it, and all processes are terminated correctly.
ngrok works fine for me with both pre-share and post-share hooks. |
rfay
left a comment
There was a problem hiding this comment.
Seems like everyhing is great now, including Windows!
The Issue
From Discord https://discord.com/channels/664580571770388500/1473660992369197127
This previously worked but no longer does and just wondering if anything has changed? The provider script is ddev generated and not changed, removing and restarting doesnt resolve the issue.
It is impossible to understand what is going on here without manually running
ngrok http http://127.0.0.1:33038I see the same situation with Cloudflared:
When
ddev share --provider=cloudflaredfailed, users saw only "Provider 'cloudflared' did not output a URL" with no error details. The actual error (e.g., "context deadline exceeded") was silently swallowed, forcing users to manually run the cloudflared command to diagnose the problem. Two bugs caused this:set -ecaused scripts to abort atwait $PIDbefore reaching diagnostic output codeHow This PR Solves The Issue
Rewrites all three share provider scripts (cloudflared, ngrok, localtunnel) to follow the same simple pattern:
cmd 2>&1 | while IFS= read -r linereplaces named pipes, temp files, background readers, and polling loopsINFfor cloudflared,lvl=infofor ngrok); errors always show--log=stdoutand parses the URL from log output instead of polling the localhost:4040 API (removes curl/jq dep)Go-side changes (share.go):
Other improvements:
PopulateShareProviders()is called fromGetShareProviderScript()so script updates take effect onddev sharewithout requiringddev restartManual Testing Instructions
ddev share --provider=ngrok- verify tunnel starts, URL is displayed, and non-info log output is visibleddev share --provider=cloudflared- verify tunnel starts, URL is displayed, and non-info log output is visiblecp .ddev/share-providers/localtunnel.sh.example .ddev/share-providers/localtunnel.sh && ddev share --provider=localtunnelddev share --provider=ngrokfor the same project - verify the second instance shows a clear errorAutomated Testing Overview
Release/Deployment Notes