Windows TCP connection fix (#12) + reloadBeforeEach option#13
Open
francislavoie wants to merge 2 commits into
Open
Windows TCP connection fix (#12) + reloadBeforeEach option#13francislavoie wants to merge 2 commits into
francislavoie wants to merge 2 commits into
Conversation
Windows can't bind a Unix domain socket, so the Rust plugin falls back to
a TCP listener, but the fixture ignored that and always dialed the socket
path — so `mode: 'tauri'` could never connect on Windows.
- Use the endpoint TauriProcessManager.start() actually detected
({ tcpPort } | { socketPath }) instead of discarding it and hardcoding
the socket path.
- For an already-running app on Windows, connect to the TCP port
(127.0.0.1:6274 by default, overridable via TAURI_PW_TCP_PORT) since
there is no socket file to wait for.
- Retry the initial connect while the app finishes booting.
Fixes srsholmes#12
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The tauri-mode fixture reloads the page (window.location.href = devUrl) before each test to reset state. On apps whose reload reboots a heavy runtime — re-running app bootstrap, reconnecting sockets, etc. — this is unsafe: the post-reload readiness poll races the reboot, and an `eval` issued while the page is mid-navigation never receives its `pw_result`, so the test hangs until the plugin's 30s eval timeout (deterministically on the first test after a cold launch). Add `reloadBeforeEach` (default `true`, so existing behavior is unchanged). Set it to `false` to run tests against the app's current shared state and avoid the reload entirely; the readiness wait is still performed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes needed to run
tauri-playwrightagainst a real Tauri app on Windows. Both are inpackages/test; behavior on macOS/Linux and existing configs is unchanged.1. Connect over TCP on Windows —
Fixes #12Problem. On Windows the Rust plugin can't bind a Unix domain socket, so it falls back to a TCP listener (
127.0.0.1:6274by default, logged aslistening on tcp://...). ButcreateTauriTest'staurimode ignores that: it always buildsnew PluginClient(socketPath)and, for an already-running app, waits for a socket file that never appears on Windows. Somode: 'tauri'can't connect on Windows at all (the TCP port returned byprocessManager.start()is dropped — #12).Fix (
fixture.ts):TauriProcessManager.start()detected ({ tcpPort }|{ socketPath }) instead of discarding it.6274, overridable viaTAURI_PW_TCP_PORT) rather than waiting for a nonexistent socket file.2.
reloadBeforeEachoption to skip the per-test page reloadWhy this was changed. The
tauri-mode fixture reloads the page (window.location.href = devUrl) before each test to reset state. That assumes the reload is cheap. On a heavy app it isn't: the reload re-runs the whole app bootstrap (reconnecting sockets, re-initializing services, …), which takes seconds. The fixture then waits only 500ms and issues awaitForFunctioneval to check readiness — but that eval lands while the page is still navigating/rebooting, its execution context is torn down before it can invokepw_result, and the plugin waits out its full 30s eval timeout. The result is a deterministic hang on the first test after a cold launch (the second test's reload targets the same URL and no-ops, so it slips through). This reproduces with zero user interaction.A single 500ms wait can't cover an arbitrary app's reboot time, and an eval issued mid-navigation can't be cancelled from the JS side (the socket matches responses by order, not id), so there's no clean way to make the reload robust for heavy apps from the fixture alone.
Fix (
fixture.ts+types.ts): addreloadBeforeEach(defaulttrue, so existing behavior is unchanged). Set it tofalseto skip the reload — tests then run against the app's current, shared state (reset explicitly where a test needs a clean slate). The readinesswaitForFunctionstill runs, so the page is confirmed ready either way.Testing
pnpm --filter @srsholmes/tauri-playwright typecheck/buildpass (the onetypecheckerror is pre-existing inipc-mock.test.ts, unrelated).mode: 'tauri'connects over TCP and drives the live webview; withreloadBeforeEach: false, the suite runs green in ~2.5s where it previously hung 30s and failed the first test on every cold launch.🤖 Generated with Claude Code