Forward pressed while a Back navigation is still loading is dropped; the URL and the rendered route get out of sync
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 54/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Start in src/routing.ts at the transition() comparison around lines 487–488, then inspect navigateFromRoute() around lines 613–615, which makes a similar comparison. Reproduce Back → Forward while the /slow resource is pending using the inline Vite example and compare the proposed pending-target check with the route-click path. Done means browser history and the rendered route plus useLocation() stay in sync for both cases; run the router test suite after changes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
Press Back, then press Forward before the route that Back entered has finished loading. The Forward is dropped:
- the address bar shows the Forward location;
- once the pending data resolves, the router commits and renders the Back location;
useLocation()reports the Back location.
The app stays out of sync with the URL until the user navigates to another route or reloads. A link to the rendered route does nothing, because the router believes it is already there.
The cause is that transition() returns early when the target equals reference():
While the Back transition is pending, reference() read outside it still holds the committed location, which is the page we were on before Back. Forward targets that same location, so transition() treats it as a no-op, and the pending Back transition then commits.
We hit this in a production app on pages whose data loads on entry.
Your Example Website or App
The repro is inline below, with no StackBlitz link. It is Vite + vite-plugin-solid, and its only runtime dependencies are solid-js 1.9.15 and @solidjs/router (0.15.4 or 1.0.0).
// src/main.jsx
import { render } from "solid-js/web";
import { createResource, Suspense } from "solid-js";
import { Router, Route, A, useLocation } from "@solidjs/router";
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
function Home() {
return <h1>Home</h1>;
}
// Its data takes 500 ms, so entering /slow (also via Back) is a pending transition for 500 ms
function Slow() {
const [data] = createResource(() => wait(500).then(() => "loaded"));
return <h1>Slow ({data()})</h1>;
}
function Fast() {
return <h1>Fast</h1>;
}
render(
() => (
<Router
root={(props) => (
<>
<nav>
<A href="/">home</A> | <A href="/slow">slow</A> | <A href="/fast">fast</A>
</nav>
<p id="loc">useLocation: {useLocation().pathname}</p>
<Suspense>{props.children}</Suspense>
</>
)}
>
<Route path="/" component={Home} />
<Route path="/slow" component={Slow} />
<Route path="/fast" component={Fast} />
</Router>
),
document.getElementById("app")
);
Steps to Reproduce the Bug or Issue
- Open
/, click slow, and wait until the page shows "Slow (loaded)". - Click fast.
- Press browser Back, then Forward before
/slow's 500 ms resource resolves.
Expected behavior
The page shows "Fast" at /fast.
Actual behavior:
- the address bar shows
/fast; - the page shows "Slow (loaded)";
useLocation().pathnameis/slow.
Clicking slow then changes nothing. Clicking fast recovers.
I measured this with Playwright, pressing Forward right after Back:
- Chromium 145: out of sync in 10 of 10 runs on 0.15.4, and in 10 of 10 on 1.0.0;
- Firefox 146 and WebKit 26: out of sync in 5 of 5 runs each, on 1.0.0.
With Forward 1 s after Back, after the resource had resolved, every run was correct.
Platform
- OS: Windows 11
- Browser: Chromium 145, Firefox 146, WebKit 26 (Playwright builds)
- Version:
@solidjs/router0.15.4 and 1.0.0,solid-js1.9.15.mainhas the same code. 2.0.0-next is a different implementation, and I did not test it.
Additional context
A possible fix is to compare against the pending target when there is one:
const current = lastTransitionTarget || { value: reference(), state: state() };
if (newTarget.value === current.value && newTarget.state === current.state) return;
With this change applied to the built bundle, Back → Forward ends on "Fast" in 10 of 10 runs on 0.15.4 and on 1.0.0. I have not run the router's test suite against it.
navigateFromRoute makes the same comparison with reference() (L613-L615). Clicking slow and then fast at once stays on /slow in 10 of 10 runs. URL and page agree there, but the second click is lost. The change above does not cover that path.
- Ngôn ngữ chính
- TypeScript
- Star
- 1.3k
- Fork
- 183
- Merge trung bình
- 14 giờ 35 phút
- Pull request đã merge (30 ngày)
- 52
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của solidjs/solid-router
-
<A> costs ~6us of server CPU per instance during SSR (20x a plain <a>), mostly mergeProps/splitPropsCó thể đã có người làm @birkskyum đã nhận 70 ngày trước. Đang mở1.x
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
solidjs/solid-router#583 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
1.x enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 38/100
solidjs/solid-router#518 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
solidjs/solid-router#482 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
solidjs/solid-router#459 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
handleAnchor and `blob` linksCó thể đã có người làm @aashish00021 đã nhận 80 ngày trước. Đang mở1.x enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
solidjs/solid-router#382 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của solidjs/solid-router
Issue tương tự
-
[Android] Nested transforms are composed in reverse orderCó thể đã có người làm @Danyalo đã nhận hôm nay. Đang mởRepro provided
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
software-mansion/react-native-svg#3090 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
radix-ui/primitives#4228 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
rocketride-org/rocketride-server#2705 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
archon-ready archon-size-s archon-type-bug area: web
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
coleam00/Archon#4707 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
HarperFast/grafana-datasource#177 ·