Skip to content

Safe cleanup backlog from review (write-only fields, dedup helpers, test-only dupes) #570

Closed

Description

@ivogt

Summary

Remaining "safe" dead-code / dedup / doc cleanups from the multi-agent review. These are low-risk and behavior-preserving but were left out of the stabilization PR because each is a multi-file or test-heavy edit (write-only field removals that thread through dep contracts + ~20 test fixtures, helper extractions into another module, etc.) — not the surgical, single-file changes that batch cleanly. Internal only; no consumer-facing change.

Already done in the stabilization PR (for context): removed dead exports SegmentCacheProvider/CacheConfig/CachedEntryResult/CacheStatus/RouterDependencies/LoaderRevalidationResult/OutletProvider, added missing re-exports (PrerenderPassthroughResult, OriginCheck*), removed the navigation-store singleton test-island, de-duped paramsEqual + observeStreamedHandler.

Backlog

  • RouteMatchResult.optionalParams / TrieMatchResult.optionalParams written everywhere, read nowhere. All-or-nothing removal: also drop TrieLeaf.op + its build in src/build/route-trie.ts:162-178, and migrate pattern-matching.test.ts assertions that read result.optionalParams. One coordinated commit.
  • MiddlewareEntry.mountPrefix is a required write-only field. Assigned at router.ts:344 + hardcoded null at middleware.ts:700/rsc/helpers.ts:210; read nowhere (scoping folds into fullPattern before the entry is built). Make optional/remove; ~20 mountPrefix: null test-fixture lines to update.
  • loaderPromises param threaded through revalidation but never read. Forwarded once at revalidation.ts:1390 into a function that ignores it. Removal threads through RouterContext dep type, segment-wrappers, resolveAllSegmentsWithRevalidation, the segment-resolution.ts call site, and segment-resolution-parallel-loading.test.ts.
  • middleware-cookies.ts parseCookies/serializeCookie are test-only duplicates of a private byte-for-byte copy in server/request-context.ts. Have request-context import these (removing its dupes), or delete + drop the middleware.ts:39 re-export + orphaned test blocks.
  • src/handles/index.ts barrel has zero importers. Delete (verify MetaTags is reachable elsewhere first — it may only be exported via this barrel) + update feature-file-map.md:33.
  • MiddlewareCollectableEntry re-export in middleware.ts — repoint middleware.test.ts:14 to import from ./middleware-types.js, then drop the re-export for a fully-minimal block.
  • Duplicated context-vars-non-empty predicate (keys + symbols) across two prerender entry points — extract hasContextVars(o) next to contextSet in src/context-var.ts and use it in both prerender-collection.ts and the second site.
  • ctx.reverse() fallback in createMiddlewareContext — misleading message ("route map was not provided to middleware context") and (name: string)-only signature, narrower than the public (name, params, search) ScopedReverseFunction.
  • Static-handler Response not routed through handleHandlerResult in renderStaticSegment — a Static handler returning a Response serializes a corrupt artifact instead of failing loudly. Add the if (raw instanceof Response) throw guard (behavior change on a type-forbidden misuse path; add a test).
  • Docs: tree-structure.md inTransitionScope description omits that the key predicate also covers error/notFound segment types (defensive); promote the document-cache tag-union timing-gap caveat (document-cache.ts:45-53) to a committed design-doc "Open Problems" entry.

Acceptance

Each item: grep-verified safe, gate green (typecheck / 3650+ unit / lint / format), no public-API change. Batch into one or two commits.

Activity

  1. reopened this on Jun 14, 2026
  2. ivogt commented on Jun 14, 2026

    @ivogt
    CollaboratorAuthor

    All cleanup items resolved (shipped in #573 + #575). Resolution map:

    Each was grep-verified safe, gate-green, no public-API change. Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions