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 Dev Server polling and discovery #1274

Merged
merged 2 commits into from
May 3, 2024

Conversation

jpwilliams
Copy link
Member

@jpwilliams jpwilliams commented Apr 12, 2024

Motivation

Polling and discovery in the Dev Server can be really verbose. Many frameworks, by default, will log all incoming HTTP requests, resulting in a huge spam of logs while the Dev Server is running. This makes debugging harder and it just looks messy.

In addition, the --no-discovery and --no-poll flags can unintentionally remove features, meaning users cannot achieve a balance of automatically adding the apps they want without spamming.

Description

This PR aims to clear up the confusion of these flags the functionality it controls.

In this area, there are a few scenarios to cover. This is the behaviour we're aiming for, with ⚠️ marks representing that this is not the current functionality and will be fixed in this PR.

Command App present on boot? Finds new apps? Poll working apps? Poll erroring apps?
No flags No Yes Yes Yes
--no-poll No Yes ⚠️ No Yes ⚠️
--no-discovery No No Yes Yes
--no-poll --no-discovery No No No Yes
--sdk-url Yes Yes Yes Yes
--no-poll --sdk-url Yes ⚠️ Yes ⚠️ No Yes ⚠️
--no-discovery --sdk-url Yes No Yes Yes
--no-poll --no-discovery --sdk-url Yes ⚠️ No No Yes ⚠️

From this, we see an incompatibility with --no-poll and other options. To fix this, if --no-poll is specified:

  • Allow initial discovery?
  • Continue to poll erroring apps?

With the latter, an erroring app means that either it did exist or a user manually added it via the flag or UI. If this is the case, should we poll until we find it?

UI

The UI also always shows that we are "Auto-detecting apps..." and doesn't actually check whether this feature is enabled or not.

Type of change (choose one)

  • Chore (refactors, upgrades, etc.)
  • Bug fix (non-breaking change that fixes an issue)
  • Security fix (non-breaking change that fixes a potential vulnerability)
  • Docs
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality not to work as expected)

Checklist

  • I've linked any associated issues to this PR.
  • I've tested my own changes.

Check our Pull Request Guidelines

@jpwilliams jpwilliams self-assigned this Apr 12, 2024
Copy link

vercel bot commented Apr 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated (UTC)
ui ⬜️ Ignored (Inspect) Apr 12, 2024 3:13pm

@@ -71,7 +73,7 @@ func Autodiscover(ctx context.Context) map[string]struct{} {
for _, path := range Paths {
// These requests _should_ be fast as we know a port is open,
// so we do these sequentially.
url := fmt.Sprintf("http://127.0.0.1:%d%s", port, path)
url := util.NormalizeAppURL(fmt.Sprintf("http://127.0.0.1:%d%s", port, path), false)
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes an issue where, even if polling was disabled, an app would be discovered at this URL and pinged, as this raw URL was different to the normalized URL within the existing app.

Copy link
Member

@djfarrelly djfarrelly left a comment

Choose a reason for hiding this comment

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

These are great improvements.

@jpwilliams jpwilliams marked this pull request as ready for review April 24, 2024 15:45
@jpwilliams jpwilliams merged commit 19dc235 into main May 3, 2024
12 checks passed
@jpwilliams jpwilliams deleted the fix/dev-server-polling-and-discovery branch May 3, 2024 11:08
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.

None yet

3 participants