Commit b79564b
Wait for the app route before auto-opening bin/dev (#2885)
## Problem
Fresh apps can open the browser as soon as Puma starts listening on
`localhost:3000`, before Shakapacker has finished producing
`manifest.json` and the first pack assets.
That produces a temporary `Shakapacker::Manifest::MissingEntryError`
page on cold boot even though the app would be fine a moment later. This
is especially noisy for AI tools and browser automation that immediately
inspect the first opened page.
## Summary
- wait for the requested route to return a successful or redirect HTTP
response before auto-opening the browser
- keep the existing one-time auto-open behavior, but make it align with
actual app readiness instead of raw port availability
- cover the readiness checks in `ServerManager` specs
## Testing
- bundle exec rspec
react_on_rails/spec/react_on_rails/dev/server_manager_spec.rb
- manual cold-start verification against a generated `--rsc` app after
deleting `public/packs`, confirming browser open happens only after `GET
/` returns `200 OK`
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Low risk: changes are limited to `bin/dev` developer ergonomics
(browser auto-open timing) plus additional specs; runtime/production
code paths are unaffected.
>
> **Overview**
> **Improves `bin/dev` browser auto-open reliability** by polling the
target *app route* over HTTP (success/redirect) instead of just checking
that the port is open, reducing premature opens during cold boot.
>
> Refactors route handling into normalized URL/path helpers, adds HTTP
probing via `Net::HTTP` across localhost addresses, and extends
`ServerManager` specs to cover route normalization and readiness
behavior. Also updates the Pro TanStack Router test `compatAct` helper
to require `React.act` (dropping the `react-dom/test-utils` fallback).
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
b70d747. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Improvements**
* Development server’s browser auto-open now waits for the app route to
respond over HTTP before launching the browser, reducing premature opens
when the server port is reachable but the app isn’t ready.
* **Bug Fixes**
* Treats HTTP success/redirect responses as ready and non-success
responses as not ready to avoid false positives.
* **Tests**
* Updated test coverage around browser auto-open readiness and route
normalization; test helper behavior adjusted for newer React act
availability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 4b73aef commit b79564b
4 files changed
Lines changed: 87 additions & 20 deletions
File tree
- packages/react-on-rails-pro/tests
- react_on_rails
- lib/react_on_rails/dev
- spec/react_on_rails/dev
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
| 43 | + | |
| 44 | + | |
46 | 45 | | |
47 | | - | |
48 | | - | |
49 | | - | |
| 46 | + | |
50 | 47 | | |
51 | 48 | | |
52 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
864 | 865 | | |
865 | 866 | | |
866 | 867 | | |
867 | | - | |
868 | | - | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
869 | 880 | | |
870 | | - | |
871 | | - | |
| 881 | + | |
| 882 | + | |
872 | 883 | | |
873 | 884 | | |
874 | 885 | | |
875 | 886 | | |
876 | 887 | | |
877 | 888 | | |
| 889 | + | |
878 | 890 | | |
879 | | - | |
| 891 | + | |
| 892 | + | |
880 | 893 | | |
881 | 894 | | |
882 | 895 | | |
| |||
896 | 909 | | |
897 | 910 | | |
898 | 911 | | |
899 | | - | |
| 912 | + | |
900 | 913 | | |
901 | 914 | | |
902 | 915 | | |
903 | | - | |
| 916 | + | |
904 | 917 | | |
905 | 918 | | |
906 | 919 | | |
907 | 920 | | |
908 | 921 | | |
909 | 922 | | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
914 | 935 | | |
| 936 | + | |
915 | 937 | | |
916 | | - | |
| 938 | + | |
917 | 939 | | |
| 940 | + | |
918 | 941 | | |
919 | 942 | | |
920 | 943 | | |
| |||
Lines changed: 45 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
259 | 302 | | |
260 | 303 | | |
261 | 304 | | |
| |||
1011 | 1054 | | |
1012 | 1055 | | |
1013 | 1056 | | |
1014 | | - | |
| 1057 | + | |
1015 | 1058 | | |
1016 | 1059 | | |
1017 | 1060 | | |
| |||
1025 | 1068 | | |
1026 | 1069 | | |
1027 | 1070 | | |
1028 | | - | |
| 1071 | + | |
1029 | 1072 | | |
1030 | 1073 | | |
1031 | 1074 | | |
| |||
0 commit comments