Skip to content

Detect ready dart 3#66

Closed
robbecker-wf wants to merge 3 commits intomasterfrom
dart3_detect_ready
Closed

Detect ready dart 3#66
robbecker-wf wants to merge 3 commits intomasterfrom
dart3_detect_ready

Conversation

@robbecker-wf
Copy link
Copy Markdown
Member

@robbecker-wf robbecker-wf commented Mar 31, 2026

Summary

When running webdev_proxy it runs a webdev serve process under the hood, which in turn can trigger a sometimes lengthy build process. In automated testing scenarios if you run webdev_proxy serve in the background and then immediately try to start using the server you'll get invalid responses until the build is done and the server is actually up and returning valid responses.

Under earlier versions of Dart, the build would output a message like [INFO] Succeeded after Xs ... when the build was done. Scripts in CI could then monitor the output log of the server for this message and then proceed with testing after seeing it.

But under Dart 3 (3.11 for example) the output does not include a message like this by default, so those scripts never see the ready message and hang indefinitely.

Changes

This PR runs the internal webdev serve process with verbose mode, which DOES output a message when the build is complete, but it is different. It looks like
[INFO] : Built with build_runner/jit in 45s; wrote 9875 outputs.

So, scripts can be updated to look for this new pattern :picard_win: but what about old existing scripts out there looking for the old pattern :ruh_roh: ?

This PR also now tries to detect when the server is ready by sending a request to the server each second until it gets a valid response. 🌶️ Unfortunately, this results in a good bit of noise in the output when first starting up. An explanatory note was added to explain what all this noise is about, but I still don't love it.

[INFO] Serving `web` proxy on http://localhost:8080

[INFO] Pinging server http://localhost:8080 to detect responsiveness...an exception from the server means it is not ready.
FINE: Pub 3.11.4
FINE: Package Config up to date.
ERROR - 2026-03-31 07:19:11.464926
GET /
Error thrown by handler.
ClientException with SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = localhost, port = 61152, uri=http://localhost:61148
package:shelf/shelf_io.dart 140:16  handleRequest

[INFO] http://localhost:8080 responded with 500, server is not ready yet.

and then when the build finally completes and a request succeeds the output looks like

[INFO] : Built with build_runner/jit in 45s; wrote 9875 outputs.
[INFO] http://localhost:8080 responded with 200, server is ready!
[INFO] Succeeded after 48.9 seconds

So now scripts can detect either type of ready message to tell when the server is fully ready. As a bonus, it also outputs the URL to the server again at the end of the output so you can click on it.

QA

To test this yourself, just globally activate it from git like so (with Dart 3 and/or Dart 2):

dart pub global activate webdev
dart pub global activate -sgit https://github.com/Workiva/webdev_proxy.git --git-ref dart3_detect_ready

And then give it a rip on your project to see how it goes

'run',
'webdev',
'serve',
'-v',
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

added verbose mode

@robbecker-wf robbecker-wf marked this pull request as ready for review March 31, 2026 15:08
@robbecker-wf robbecker-wf requested a review from a team as a code owner March 31, 2026 15:08
Copy link
Copy Markdown

@dustinlessard-wf dustinlessard-wf left a comment

Choose a reason for hiding this comment

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

It looks like retries are unbounded and we should probably set a limit of some kind?

@robbecker-wf
Copy link
Copy Markdown
Member Author

closing in favor of #67

@robbecker-wf robbecker-wf deleted the dart3_detect_ready branch April 1, 2026 20:33
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