Skip to content

Commit

Permalink
Fix Dev Server polling and discovery (#1274)
Browse files Browse the repository at this point in the history
* Normalize URLs when found via dev server

This allows better matching to know when to avoid polling

* Poll existing-but-erroring apps, even if polling is off
  • Loading branch information
jpwilliams committed May 3, 2024
1 parent 7e2c1a4 commit 19dc235
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion pkg/devserver/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"strconv"
"sync"
"time"

"github.com/inngest/inngest/pkg/util"
)

var (
Expand Down Expand Up @@ -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)
if err := checkURL(ctx, url); err == nil {
if _, ok := urls[url]; !ok {
// only add if the URL doesn't exist; this ensures
Expand Down
8 changes: 5 additions & 3 deletions pkg/devserver/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ func (d *devserver) Pre(ctx context.Context) error {

func (d *devserver) Run(ctx context.Context) error {
// Start polling the SDKs as the APIs are going live.
if d.opts.Poll {
go d.pollSDKs(ctx)
}
go d.pollSDKs(ctx)

// Add a nice output to the terminal.
if isatty.IsTerminal(os.Stdout.Fd()) {
Expand Down Expand Up @@ -237,6 +235,10 @@ func (d *devserver) pollSDKs(ctx context.Context) {
// We've seen this URL.
urls[app.Url] = struct{}{}

if !d.opts.Poll && len(app.Error.String) == 0 {
continue
}

// Make a new PUT request to each app, indicating that the
// SDK should push functions to the dev server.
res := deploy.Ping(ctx, app.Url)
Expand Down

0 comments on commit 19dc235

Please sign in to comment.