Skip to content

fix(dev): fix frontend dev server startup race#5776

Open
savely-krasovsky wants to merge 1 commit into
wailsapp:masterfrom
savely-krasovsky:fix-windows-bug
Open

fix(dev): fix frontend dev server startup race#5776
savely-krasovsky wants to merge 1 commit into
wailsapp:masterfrom
savely-krasovsky:fix-windows-bug

Conversation

@savely-krasovsky

@savely-krasovsky savely-krasovsky commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes a race in wails3 dev where the native application may exit before the frontend dev server becomes ready.

The watcher starts the frontend task in the background and immediately launches the application. Previously, the application stopped waiting after 10 attempts at 500 ms intervals. Frontends that took slightly longer than five seconds to start caused a fatal error.

Fixes # (issue)

Type of change

Please select the option that is relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using wails doctor.

  • Windows
  • macOS
  • Linux

If you checked Linux, please specify the distro and version.

Test Configuration

Please paste the output of wails doctor. If you are unable to run this command, please describe your environment in as much detail as possible.

Checklist:

  • (v2 only) I have updated website/src/pages/changelog.mdx with details of this PR (v3 changelog entries are added automatically)
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • Bug Fixes

    • Improved frontend development server startup checks with repeated readiness attempts.
    • Startup now stops promptly when canceled and reports connection or URL errors clearly instead of terminating abruptly.
    • Added request timeouts to prevent readiness checks from hanging.
  • Tests

    • Added coverage for retries, cancellation, successful response handling, and invalid server URLs.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The development startup path now uses a context-aware helper to probe the frontend server with timed retries and HTTP timeouts. Errors are returned from preRun, and non-production tests cover retries, cancellation, response cleanup, and invalid URLs.

Changes

Frontend readiness

Layer / File(s) Summary
Context-aware readiness probe
v3/pkg/application/application_dev.go
preRun delegates frontend readiness checks to a retrying helper that uses cloned context requests, timed intervals, HTTP timeouts, and returned errors.
Readiness probe validation
v3/pkg/application/application_dev_test.go
Tests verify retries, response-body closure, cancellation, retry reporting, and invalid URL errors.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant preRun
  participant waitForFrontendDevServer
  participant httpClient
  participant FrontendDevServer
  participant Context
  preRun->>waitForFrontendDevServer: readiness URL and context
  waitForFrontendDevServer->>httpClient: execute cloned GET request
  httpClient->>FrontendDevServer: probe frontend server
  FrontendDevServer-->>httpClient: response or connection error
  waitForFrontendDevServer->>Context: check cancellation between attempts
  waitForFrontendDevServer-->>preRun: success or returned error
Loading

Poem

A rabbit hops through retries bright,
With timers ticking through the night.
The frontend answers, doors unlock,
Or context stops the ticking clock.
Errors return, neat and clear—
Tests keep every pathway dear.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: fixing the frontend dev server startup race.
Description check ✅ Passed The description follows the template and includes a clear summary and test checklist, though the fixed issue is still left as a placeholder.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@savely-krasovsky

Copy link
Copy Markdown
Contributor Author

This was my constant struggle while I develop Windows App. I don't know, maybe because of Windows Defender or something else, but on Windows frontend part start kind of long and I was contantly getting this race:

$ wails3 dev
Wails v3.0.0-alpha2.117 › Build
task: [windows:common:go:mod:tidy] go mod tidy
task: Task "windows:common:generate:icons" is up to date
task: [windows:common:go:mod:tidy] go mod tidy
task: [windows:common:install:frontend:deps] pnpm install
Already up to date
Done in 39ms using pnpm v11.8.0
task: [generate:bindings (BUILD_FLAGS=-buildvcs=false -gcflags=all="-l")] wails3 generate bindings -f '-buildvcs=false -gcflags=all="-l"' -clean=true -ts
Wails v3.0.0-alpha2.117 › Generate Bindings
 INFO  Processed: 332 Packages, 1 Service, 33 Methods, 40 Enums, 152 Models, 3 Events in 1.0032622s.                                                                                                      
 INFO  Output directory: D:\projects\fidoapp\frontend\bindings
task: [build:frontend (DEV=true)] pnpm run build:dev
$ vite build --minify false --mode development
vite v8.0.16 building client environment for development...
✔ [paraglide-js] Compilation complete (message-modules)                                                                                                                                                
✓ 5746 modules transformed.
computing gzip size...
dist/index.html                                                       0.39 kB │ gzip:   0.28 kB
dist/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2      7.50 kB
dist/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2           9.00 kB
dist/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2       12.10 kB
dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2      15.19 kB
dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2          40.40 kB
dist/assets/index-Bf6eh-vi.css                                      170.34 kB │ gzip:  26.53 kB
dist/assets/index-B8pXrTFH.js                                     2,640.94 kB │ gzip: 411.61 kB

[PLUGIN_TIMINGS] Your build spent significant time in plugins. Here is a breakdown:
  - wails-typed-events (85%)
  - vite-plugin-svelte:compile (7%)
  - vite-plugin-svelte:preprocess (7%)
See https://rolldown.rs/options/checks#plugintimings for more details.

✓ built in 4.75s
task: [windows:generate:syso] wails3 generate syso -arch amd64 -icon windows/icon.ico -manifest windows/wails.exe.manifest -info windows/info.json -out ../wails_windows_amd64.syso
task: [windows:build:native] go build -buildvcs=false -gcflags=all="-l" -o "bin/fidoapp.exe"
task: [windows:build:native] powershell Remove-item *.syso

Need documentation? Run: wails3 docs
 ♥   If Wails is useful to you or your company, please consider sponsoring the project: wails3 sponsor
task: [windows:run] bin/fidoapp.exe
Jul 13 02:36:23.779 INF Build Info: Wails=v3.0.0-alpha2.117 Compiler=go1.26.4 -compiler=gc -gcflags=all=-l CGO_ENABLED=0 GOARCH=amd64 GOOS=windows GOAMD64=v1 -buildmode=exe
Jul 13 02:36:23.780 INF AssetServer Info: middleware=true handler=true devServerURL=http://localhost:9245
Jul 13 02:36:23.780 INF Platform Info: Go-WebView2Loader=true WebView2=150.0.4078.65 ID=25H2 Name=Windows 10 Pro Version=2009 (Build: 26200) Branding=Windows 11 Pro
Jul 13 02:36:23.780 INF Waiting for frontend dev server to start... url=http://localhost:9245
task: [common:install:frontend:deps] pnpm install
Jul 13 02:36:24.287 INF Retrying...
Already up to date
Done in 28ms using pnpm v11.8.0
task: [common:dev:frontend] pnpm run dev -- --port 9245 --strictPort
Already up to date
Done in 27ms using pnpm v11.8.0
$ vite "--" "--port" "9245" "--strictPort"
Jul 13 02:36:25.289 INF Retrying...
Jul 13 02:36:26.291 INF Retrying...
Jul 13 02:36:27.293 INF Retrying...
Jul 13 02:36:28.295 INF Retrying...
✔ [paraglide-js] Compilation complete (locale-modules)                                                                                                                                                 

  VITE v8.0.16  ready in 3257 ms

  ➜  Local:   http://127.0.0.1:9245/
Jul 13 02:36:28.797 ERR 

******************************** FATAL *********************************
*      There has been a catastrophic failure in your application.      *
**************************** Error Details *****************************
unable to connect to frontend server. Please check it is running - FRONTEND_DEVSERVER_URL='http://localhost:9245'************************************************************************

  ERROR   task: Failed to run task "run": exit status 1

This PR fixes my issues completely.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@v3/pkg/application/application_dev.go`:
- Around line 25-26: Update the frontend readiness loop around client.Get in
application startup to enforce a request timeout, using an http.Client with a
finite Timeout or a context deadline for each request. Preserve the existing
retry behavior while ensuring an unresponsive frontend cannot block startup
indefinitely.
- Line 25: Update the retry documentation associated with the loop in
application startup to state that the server is retried a maximum of 30 times,
matching the loop’s 30 iterations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 54c051b6-72c9-4c79-b358-c53a6af957ca

📥 Commits

Reviewing files that changed from the base of the PR and between 3440ae5 and fc9f35a.

📒 Files selected for processing (2)
  • v3/internal/commands/dev.go
  • v3/pkg/application/application_dev.go

Comment thread v3/pkg/application/application_dev.go Outdated
Comment thread v3/pkg/application/application_dev.go Outdated
@savely-krasovsky savely-krasovsky changed the title fix(dev): use loopback IP and increase frontend server wait timeout fix(dev): fix frontend dev server startup race Jul 18, 2026
@savely-krasovsky

Copy link
Copy Markdown
Contributor Author

@leaanthony could you review please? This is SO persistent on Windows, I am tired to restart wails3 dev for ten times to just finally launch it :( This commit fixes issue completely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant