Skip to content

Commit

Permalink
assets: report error if webpack dev port in use (#4344)
Browse files Browse the repository at this point in the history
Webpack listens on IPv4, Go will happily bind to the same port
when we do an upfront check for the port being open.

In theory, we could just let Webpack error out and let us know
that the port is in use, but because it thinks it's running in
interactive mode, it helpfully pops up a message and offers to
let you pick a different port, which we'll never see. Running
it without any stdin attached _would_ cause it to error and
show the issue on macOS at least, but we started attaching a
dummy stdin in #3388 for other Webpack/CRA issues in the first
place (likely OS-specific), so this is a reasonable compromise.
  • Loading branch information
milas committed Mar 22, 2021
1 parent 477c196 commit c1e6710
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/assets/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (s *devServer) start(ctx context.Context, stdout, stderr io.Writer) (*exec.

func (s *devServer) Serve(ctx context.Context) error {
// webpack binds to 0.0.0.0
l, err := net.Listen("tcp", fmt.Sprintf(":%d", int(s.port)))
l, err := net.Listen("tcp4", fmt.Sprintf(":%d", int(s.port)))
if err != nil {
return errors.Wrapf(err, "Cannot start Tilt dev webpack server. "+
"Maybe another process is already running on port %d? "+
Expand Down

0 comments on commit c1e6710

Please sign in to comment.