Skip to content

fix(fresh/navigation): native POST partials bypass the generation fence and can reopen a closed view #2647

Open

Description

@rickylabs

Summary

In @netscript/fresh@0.0.9, a native managed-form POST bypasses the navigation coordinator's generation fence. Hold a successful POST partial after its one server effect, navigate the view closed through a later native GET, then release the POST answer: its old partial can reopen the closed view. The URL/visible state can also be restored by that stale answer. No command resend is involved.

Downstream: Garage Booking #522. Related shipped ordering feature #1590. This differs from #2625 (classification/supersession of GET deferred regions).

Minimal reproduction

  1. Install the native installPartialNavigationCoordinator() once in the client entry. Render a native withForm/Form POST inside a KeyedPartial-backed sheet. The successful POST returns that sheet partial. A normal typed anchor/GET partial closes it.
  2. Hold only the POST's answer after the server commits its single effect. Let later GETs run normally.
  3. Submit the command, then activate Close/Escape. Wait for the close GET to apply: the sheet is absent and its query parameter is gone.
  4. Release the older POST answer.
  5. Observed: the sheet reappears. Expected: it remains closed; a later deliberate reopen still works. Server command/effect count stays exactly one throughout.

Minimal browser interception for an existing native-form fixture (selectors are the fixture's):

let release, committed;
const held = new Promise((resolve) => release = resolve);
const answered = new Promise((resolve) => committed = resolve);
await page.route('**/staff/**', async (route) => {
  if (route.request().method() !== 'POST') return route.continue();
  const response = await route.fetch(); // native server has answered; effect already occurred
  committed();
  await held;                         // later native close GET remains unblocked
  await route.fulfill({ response });
});
await command.click();
await answered;
await page.keyboard.press('Escape');
await expect(sheet).toBeHidden();
release();
await page.waitForLoadState('networkidle'); // this minimal fixture has no background streams
// The stale native POST currently makes sheet visible again.
await expect(sheet).toBeHidden();

The retained downstream production probe already demonstrated the case with a 1200ms held post-command detail answer: staff_unconfirmed_browser.mjs at560df11d, regression('slow'). It observed one command/one committed effect. This report adds exact released API/source qualification; the reduced snippet above was not separately executed. No live/candidate probe was run for this report.

Exact released source/API

0.0.9 coordinator.ts:

  • onSubmit, lines188–205: line194 returns when the form method is not GET, so POST never stages a navigation intent.
  • interceptFetch, lines231–248: lines235–239 pass every non-GET straight to platformFetch, so POST receives no NavigationLease/ManagedPartialBody or stale-body suppression.
  • invalidReason, lines254–261: generation checks cover only responses that obtained that lease.

Locked deno doc --frozen-lockfile --filter PartialNavigationCoordinator jsr:@netscript/fresh@0.0.9/navigation confirms the public handle is navigate/subscribe/dispose. FormEnhancementOptions offers void start/end callbacks; no pre-application gate was found. Application source uses existing native anchors/forms and one coordinator. The pre-existing command-resend defect was fixed separately downstream and is not part of this report.

Smallest expected native change

Order native POST partial answers by the same page/region generation as native GET navigation, staging/assigning the lease at the supported submission seam. A later close/page/region intent must suppress the older answer's DOM/history application while draining it safely. Alternatively expose a supported form result gate before native partial/history application; an end callback after application cannot prevent this race.

Do not automatically repeat a command, abort it as if that rolls back a server effect, alter its idempotency key, or force applications to wrap fetch/history/HTML markers.

Acceptance

  • Held POST answer released after a later native close GET cannot reopen/repaint or restore stale history.
  • Exactly one command and one effect; original key unchanged; later manual reopen works.
  • Cover successful, validation-error and uncertain POST answers, page/region changes and disposal; preserve existing GET ordering/drain behavior without Vite abort overlays.
  • Public docs identify whether managed POST partials share the ordering contract or name the new pre-apply result gate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions