Navigation commit failure leaves the loading state active and causes inconsistent internal state
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- react, typescript
調査の方向性
Read packages/react/src/runtime/pages-client.ts around finishNavigation() and packages/void/src/pages/navigation-engine.ts around makeCommit(). Trace how pending visits, reducer failure actions, internal committed state, and scrollRestoration.writeHistory() interact when history writing throws. Reproduce with the provided component and verify the error propagates, navigation returns to idle, state stays consistent, and an older failure cannot reset a newer navigation.
索引モデルが issue の本文から書いたものです。
説明
Problem
When history.pushState() or history.replaceState() throws during navigation, router.visit() rejects, but useNavigation().state remains loading.
Additionally, Void updates its internal committed state before writing browser history. If the history update fails, the browser URL and internal navigation state become inconsistent.
Reproduction
- Configure a valid Void page at
/b. - Render the following React component:
import { useNavigation, useRouter } from '@void/react';
export default function Example() {
const router = useRouter();
const navigation = useNavigation();
async function navigate() {
const original = history.pushState;
history.pushState = () => {
throw new DOMException(
'History update failed',
'SecurityError',
);
};
try {
await router.visit('/b');
} catch {
// Inspect the navigation state after failure.
} finally {
history.pushState = original;
}
}
return (
<>
<p>Navigation: {navigation.state}</p>
<button onClick={navigate}>Navigate</button>
</>
);
}
- Click the button and inspect the navigation state and browser URL after the failed navigation.
Actual behavior
router.visit()rejects.useNavigation().stateremainsloading.- The browser URL remains unchanged.
- Void's internal current URL and committed resource have already been updated.
- Restoring normal history behavior and navigating to another page clears the stuck navigation state.
Expected behavior
A failed history update should terminate the navigation cleanly and preserve state consistency.
- The navigation state returns to
idle. - The original error propagates to the
router.visit()caller. - The browser URL, rendered page, and internal navigation state remain consistent.
- Subsequent navigations continue to work normally.
Root cause
In packages/react/src/runtime/pages-client.ts, finishNavigation() rejects the visit promise when resource.commit() fails, but does not clear the active pending navigation or dispatch a failure action.
resource.commit()
.then((committed) => {
// Successful navigation cleanup.
})
.catch((error) => {
const visitSettler = pendingVisitSettlers.get(resource.id);
if (visitSettler) {
pendingVisitSettlers.delete(resource.id);
visitSettler.reject(error);
}
});
The reducer already supports fail and abandon actions that reset the navigation state, but neither is dispatched in this failure path.
Additionally, in packages/void/src/pages/navigation-engine.ts, makeCommit() modifies internal navigation state before updating browser history.
_urlNavigationId = resourceId;
// Update committed resource and deferred registry ownership.
applyClientHead(result.pageData.head as HeadDescriptor | undefined);
_currentFetchUrl = commitTarget.fetchUrl;
if (!options._popstate) {
const historyUrl = commitTarget.fetchUrl + commitTarget.hash;
scrollRestoration.writeHistory(historyUrl, !!options.replace);
}
If scrollRestoration.writeHistory() throws, the earlier internal state mutations are not rolled back, leaving the commit partially applied.
Suggested fix
- Ensure the React adapter clears the active pending navigation and dispatches the appropriate failure or rollback action when
resource.commit()rejects. - Make
makeCommit()failure-safe so that a failed history update cannot leave internal committed state inconsistent with browser history. - Ensure cleanup for a failed navigation does not overwrite or reset a newer navigation.
- Preserve existing resource lifecycle management, deferred registry ownership, and navigation ordering guarantees.
Acceptance criteria
- A failed
history.pushState()orhistory.replaceState()does not leave navigation inloadingorsubmitting. router.visit()rejects with the original error.- The browser URL, rendered page, and internal navigation state remain consistent after failure.
- Subsequent navigations work normally.
- Cleanup from an older failed navigation does not modify the state of a newer navigation.
Related issues
- #506 — preserveState prevents the destination URL from being committed (Closed)
- #507 — An older navigation can overwrite the URL after a newer navigation commits (Closed)
- #527 — Pages: actions commit the
?actionNameURL to history (Open)
Unlike these issues, this report concerns error handling and state consistency when a browser history update throws during navigation commit.
- 主要言語
- TypeScript
- スター
- 580
- フォーク
- 56
- 平均マージ
- 8時間 36分
- マージ済み PR(30日)
- 110
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
voidzero-dev/void のほかの issue
-
Static Cloudflare deploy ignores `cloudflare.assets.html_handling`対応中かも @0froq が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
voidzero-dev/void#580 ·
メンテナーはふだん 1 日以内に返信
-
`void/log` serializes `Error` fields as `{}`, losing message and stack対応中かも @RaphaelFakhri が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
voidzero-dev/void#577 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
voidzero-dev/void#576 ·
メンテナーはふだん 1 日以内に返信
-
Dev: `better-auth/client/plugins` fails to resolve when auth is enabled (the `better-auth/client` alias matches it as a prefix)対応中かも @MaxtuneLee が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
voidzero-dev/void#565 ·
メンテナーはふだん 1 日以内に返信
-
prepareDeployArtifact omits worker.vars that the CLI managed deploy includes対応中かも @dvkam が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
voidzero-dev/void#529 ·
メンテナーはふだん 1 日以内に返信
voidzero-dev/void の issue をすべて見る
似ている issue
-
freshness freshness:observed-only
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
thoroc/context-radar#282 ·
-
bug P2 rust
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
area: web
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
gabe-santana/arkdraw#25 ·
-
bug require-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
expressjs/expressjs.com#2549 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug good first issue hacktoberfest
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
codercops/discord-bot#101 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信