Skip to content

Refactor internal request handling into a functional core - #17636

Merged
matthewp merged 20 commits into
mainfrom
fetch-refactor-2
Aug 13, 2026
Merged

matthewp merged 20 commits into
mainfrom
fetch-refactor-2

Conversation

@matthewp

@matthewp matthewp commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Changes

  • Primary purpose of this pull-request is to refactor internal requests to get rid of the Pipeline and App classes as used internally. These were essentially "god objects" that held state related to the server-side app.
  • The problem with these objects were that there was no way to pass them into FetchState when access from outside of the App class. For example in Cloudflare you can create a custom worker which is the entrypoint to the application.
  • I realized that the manifest is the one true god-object in SSR, and we could simply derive all state from that. So this new architecture is much more functional. Derived state is created as createManifestMemo and createAsyncManifestMemo which are keyed on the manifest. Anything that needs this state can simply import it now.
  • Everything else in this PR is just conforming to the above.
  • App remains as its the external API for adapters, but mostly just defers to the functional approach now.

Fixes #17591

Testing

  • Mostly refactored existing tests which relied in the Pipeline.

Docs

  • N/A, just a refactor

Replace the App/Pipeline god objects with pure functions drawing static
data from the manifest (the only permitted ambient source of truth):

- All internal handler classes (AstroHandler, PagesHandler, AstroMiddleware,
  CacheHandler, ActionHandler, I18n, Rewrites, TrailingSlashHandler, error
  handlers, session provider) are now module functions rooted in FetchState.
- FetchState constructs from (manifest, request, options?, hooks?); the
  public one-arg new FetchState(request) works from a bare Request by
  reaching the manifest module directly (ambient), with no app handle.
- Symbol.for('astro.app') and Symbol.for('astro.pipeline') are deleted;
  nothing static rides the request. Render options carry only render()
  inputs.
- Environment differences (prod SSR, dev runnable/non-runnable, build,
  container) are per-manifest RenderEnvironment records composed at
  entrypoint time; production is the zero-setup default.
- Process-lifetime derivations (route table, middleware, actions, session
  driver, cache provider, logger, renderers) are WeakMap memos keyed by
  the manifest in their owning modules.
- App and NodeApp remain public facades with unchanged signatures; every
  method delegates to the functional core. app.pipeline survives as a
  stateless compat shim. Pipeline base and all subclasses are deleted.
- Dev HMR route updates are now atomic (fixes stale-router split-brain).

No public API changes. All suites green: unit, full integration,
@astrojs/node, @astrojs/cloudflare (workerd), dev/HMR.
@changeset-bot

changeset-bot Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f484912

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 420 packages
Name Type
astro Patch
@astrojs/node Patch
@e2e/astro-linked-lib Patch
@e2e/actions-blog Patch
@e2e/actions-react-19 Patch
@e2e/astro-component Patch
@e2e/astro-envs Patch
@e2e/astro-island-hydration-error Patch
@test/astro-cloudflare-node-prerender-mdx Patch
@test/astro-cloudflare Patch
@e2e/content-collections Patch
@e2e/csp-server-islands Patch
@e2e/css Patch
@test/custom-client-directives Patch
@e2e/dev-toolbar Patch
@e2e/error-cyclic Patch
@e2e/error-sass Patch
@e2e/errors Patch
@e2e/hydration-race Patch
@e2e/i18n Patch
@test/nested-style-bug-e22e Patch
@e2e/preact-compat-component Patch
@e2e/preact-component Patch
@e2e/preact-lazy-component Patch
@e2e/prefetch Patch
@e2e/react-component Patch
@e2e/server-islands-key Patch
@e2e/server-islands Patch
@e2e/solid-circular Patch
@e2e/solid-component Patch
@e2e/solid-recurse Patch
@e2e/svelte-component Patch
@e2e/e2e-tailwindcss Patch
@e2e/ts-resolution Patch
@e2e/view-transitions Patch
@e2e/vue-component Patch
@performance/md Patch
@performance/mdoc Patch
@performance/mdx Patch
@test/0-css Patch
fake-astro-library Patch
@test/actions Patch
@test/alias-css-url-data-uri Patch
@test/alias-css-url Patch
@test/alias-path-alias-style Patch
@test/ts-paths-no-baseurl Patch
@test/aliases-tsconfig Patch
@test/aliases Patch
@test/api-routes Patch
@test/asset-query-params-chunks Patch
@test/asset-url-base Patch
@test/astro-pages Patch
@test/astro-assets-prefix Patch
@test/astro-assets Patch
@test/astro-basic Patch
@test/astro-check-errors Patch
@test/astro-check-no-errors Patch
@test/astro-check-watch Patch
@test/astro-children Patch
@test/astro-client-only Patch
@test/astro-component-bundling Patch
@test/astro-component-code Patch
@test/astro-css-bundling Patch
@test/astro-dev-headers Patch
@test/astro-dev-http2 Patch
@test/astro-doctype Patch
@test/astro-dynamic Patch
@test/astro-env-content-collections Patch
@test/astro-env-required-public Patch
@test/astro-env-server-fail Patch
@test/astro-env-server-secret Patch
@test/astro-env Patch
@test/astro-envs Patch
@test/astro-expr Patch
@test/astro-get-static-paths Patch
@test/astro-head Patch
@test/astro-manifest-client-script Patch
@test/astro-manifest-invalid Patch
@test/astro-manifest Patch
@test/astro-markdown-frontmatter-injection Patch
@test/astro-markdown-plugins Patch
@test/astro-markdown-remarkRehype Patch
@test/astro-markdown-skiki-default-color Patch
@test/astro-markdown-skiki-langs Patch
@test/astro-markdown-skiki-themes-custom Patch
@test/astro-markdown-skiki-themes-integrated Patch
@test/astro-markdown-skiki-wrap-false Patch
@test/astro-markdown-skiki-wrap-null Patch
@test/astro-markdown-skiki-wrap-true Patch
@test/astro-markdown-url Patch
@test/astro-markdown Patch
@test/astro-mode Patch
@test/astro-page-directory-url Patch
@test/astro-partial-html Patch
@test/astro-preview-allowed-hosts Patch
@test/astro-preview-headers Patch
@test/astro-public Patch
@test/astro-script-template-dedup Patch
@test/astro-scripts Patch
@test/astro-slots-nested Patch
@test/concurrency Patch
@test/build-readonly-file Patch
@test/cache-memory-query-include Patch
@test/cache-memory-query Patch
@test/client-address-node Patch
@test/client-only-child-styles Patch
@test/client-only-css-chunk-leak Patch
@test/code-component Patch
@test/component-library Patch
@test/config-vite-css-target-no-minify Patch
@test/config-vite-css-target Patch
@test/config-vite Patch
@test/react-container Patch
@test/content-with-spaces-in-folder-name Patch
@test/content-collection-picture-render Patch
@example/content-collection-references Patch
@test/content-collection-tla-svg Patch
@test/content-collections-base Patch
@test/content-collections-empty-dir Patch
@test/content-collections-empty-md-file Patch
@test/content-collections-image-hmr Patch
@test/content-collections-mutation Patch
@test/content-collections-number-id Patch
@test/content-collections-type-inference Patch
@test/content-collections-with-config-mjs Patch
@test/content-collections Patch
@test/content-frontmatter Patch
@test/content-intellisense Patch
@test/content-layer-loader-schema-function Patch
@test/content-layer-remark-plugins Patch
@test/content-layer Patch
@test/content-ssr-integration Patch
@test/content-static-paths-integration Patch
@test/content Patch
@test/core-image-data-url Patch
@test/core-image-deletion-ssr Patch
@test/core-image-deletion Patch
@test/core-image-errors Patch
@test/core-image-fs-config Patch
@test/core-image-remark-infersize Patch
@test/core-image-layout Patch
@test/core-image-picture-emit-file Patch
@test/core-image-remark-imgattr Patch
@test/core-image-ssg Patch
@test/core-image-ssr Patch
@test/core-image-svg-in-client Patch
@test/core-image-svg Patch
@test/core-image-unconventional-settings Patch
@test/core-image Patch
@test/csp-adapter Patch
@test/csp-fonts Patch
@test/csp Patch
@test/css-assets Patch
@test/css-dangling-references Patch
@test/css-deduplication Patch
@test/css-double-bundle Patch
@test/css-dynamic-import-dev Patch
@test/css-import-as-inline Patch
@test/css-inline-stylesheets Patch
@test/css-no-code-split Patch
@test/css-path-case Patch
@test/css-pure-chunk-query-params Patch
@test/css-server-output-dedup Patch
@test/custom-404-injected-from-dep Patch
@test/custom-404-pkg Patch
custom-fetch-error-pages Patch
@test/custom-renderer Patch
@test/data-collections-schema Patch
@test/data-collections Patch
@test/debug-component Patch
@test/dev-container Patch
@test/dev-render Patch
@test/dev-request-url Patch
@test/dynamic-endpoint-collision Patch
@test/dynamic-route-build-file Patch
@test/endpoint-routing Patch
@test/error-bad-js Patch
@test/error-build-location Patch
@test/error-non-error Patch
@test/extension-matching Patch
@test/fetch Patch
@test/fonts Patch
@test/astro-fontsource-package Patch
@test/get-static-paths-pages Patch
@test/glob-pages-css Patch
@test/head-propagation-prerender-env Patch
@test/hmr-markdown Patch
@test/hmr-middleware Patch
@test/hmr-new-page Patch
@test/hmr-slots-render Patch
@test/hoisted-imports Patch
@test/html-component Patch
@test/html-escape Patch
@test/html-page Patch
@test/html-slots Patch
@test/hydration-race Patch
@test/i18n-client-import Patch
@test/i18n-css-leak-basic Patch
@test/import-ts-with-js Patch
@test/impostor-md-file Patch
@test/incremental-build-client-only Patch
@test/incremental-build-concurrency Patch
@test/incremental-build-content Patch
@test/incremental-build-drop-key Patch
@test/incremental-build-dynamic-import Patch
@test/incremental-build-fonts Patch
@test/incremental-build-headers Patch
@test/incremental-build-images Patch
@test/incremental-build-islands Patch
@test/incremental-build-no-output Patch
@test/incremental-build-script Patch
@test/incremental-build Patch
@test/integration-add-page-extension Patch
@test/integration-server-setup Patch
@test/jsx-queue-rendering Patch
@test/large-array-solid Patch
@test/legacy-collections-backwards-compat Patch
@test/lightningcss-css-modules-content Patch
@test/lightningcss-scoped-nesting Patch
@test/live-loaders Patch
@test/markdown Patch
@test/middleware-dev Patch
@test/middleware-full-ssr Patch
@test/middleware-no-user-middlewaqre Patch
@test/middleware-tailwind Patch
@test/minification-html-default Patch
@test/minification-html-jsx Patch
@test/minification-html Patch
@test/non-ascii-path Patch
@test/non-html-pages Patch
@test/page-format Patch
@test/page-level-styles Patch
@test/parallel-components Patch
@test/partials-css-boundary Patch
@test/partials Patch
@test/passthrough-image-service Patch
@test/postcss Patch
@test/preact-compat-component Patch
@test/preact-component Patch
@test/remote-css Patch
@test/request-signal Patch
@test/reuse-injected-entrypoint Patch
@test/root-srcdir-css Patch
@test/scoped-style-strategy Patch
@test/server-entry-fake-adapter Patch
@test/server-entry Patch
@test/server-islands-hybrid Patch
@test/server-islands-ssr Patch
@test/session-false Patch
@test/session-tree-shake Patch
@test/sessions Patch
@test/slots-preact Patch
@test/slots-react Patch
@test/slots-solid Patch
@test/slots-svelte Patch
@test/slots-vue Patch
@test/solid-component Patch
@test/sourcemap Patch
@test/space-in-folder-name Patch
@test/special-chars-in-component-imports Patch
@test/ssr-assets Patch
@test/ssr-dynamic Patch
@test/ssr-partytown Patch
@test/ssr-prerender-get-static-paths Patch
@test/ssr-prerender Patch
@test/ssr-preview Patch
@test/ssr-renderers-static-vue Patch
@test/ssr-request Patch
@test/ssr-hoisted-script Patch
@test/ssr-scripts Patch
@test/static-build-code-component Patch
@test/static-build-dir Patch
@test/static-build-frameworks Patch
@test/static-build-page-url-format Patch
@test/static-build-ssr Patch
@test/static-build Patch
@test/static-redirect Patch
@test/svelte-component Patch
@test/svg-deduplication Patch
@test/tailwindcss Patch
@e2e/third-party-astro Patch
@test/url-import-suffix Patch
@test/view-transitions Patch
@test/virtual-astro-file Patch
@test/vite-virtual-modules Patch
@test/vitest Patch
@test/vue-component Patch
@test/vue-with-multi-renderer Patch
@test/alpinejs-basics Patch
@test/alpinejs-directive Patch
@test/alpinejs-plugin-script-import Patch
@test/astro-cloudflare-allowed-hosts Patch
@test/astro-cloudflare-astro-dev-platform Patch
@test/astro-cloudflare-astro-env Patch
@test/astro-cloudflare-binding-image-cache Patch
@test/astro-cloudflare-binding-image-service Patch
@test/astro-cloudflare-cache-provider-wait-until Patch
@test/astro-cloudflare-cache-provider Patch
@test/astro-cloudflare-client-address Patch
@test/astro-cloudflare-compile-custom-image-service Patch
@test/astro-cloudflare-compile-image-service Patch
@test/astro-cloudflare-custom-entryfile-fetch-state Patch
@test/astro-cloudflare-custom-entryfile Patch
@test/astro-cloudflare-custom-image-service Patch
@test/astro-cloudflare-dev-image-endpoint Patch
@test/astro-cloudflare-external-image-service Patch
@test/astro-cloudflare-external-redirects Patch
@test/cloudflare-incremental-images Patch
@test/astro-cloudflare-internal-redirects Patch
@test/astro-cloudflare-no-output Patch
@test/astro-cloudflare-prerender-node-env Patch
@test/astro-cloudflare-prerender-queue-consumers Patch
@test/astro-cloudflare-prerender-styles Patch
@test/astro-cloudflare-prerenderer-errors Patch
@test/astro-cloudflare-prerenderer-render-error Patch
@test/routing-priority-cloudflare Patch
@test/cf-server-entry Patch
@test/astro-cloudflare-server-island-prerender-framework Patch
@test/astro-cloudflare-sql-import Patch
@test/cf-ssr-deps Patch
@test/astro-cloudflare-static Patch
@test/astro-cloudflare-svelte-rune-deps Patch
@test/astro-cloudflare-top-level-return Patch
@test/cf-user-optimize-deps Patch
@test/astro-cloudflare-vite-plugin Patch
@test/astro-cloudflare-with-base Patch
@test/astro-cloudflare-with-react Patch
@test/astro-cloudflare-with-solid-js Patch
@test/astro-cloudflare-with-svelte Patch
@test/astro-cloudflare-with-vue Patch
@test/astro-cloudflare-wrangler-preview-platform Patch
@test/markdoc-content-collections Patch
@test/content-layer-markdoc Patch
@test/headings-custom Patch
@test/headings Patch
@test/image-assets-custom Patch
@test/image-assets Patch
@test/markdoc-propagated-assets Patch
@test/markdoc-render-with-space Patch
@test/markdoc-render-html Patch
@test/markdoc-render-null Patch
@test/markdoc-render-partials Patch
@test/markdoc-render-simple Patch
@test/markdoc-render-table-attrs Patch
@test/markdoc-render-this-context Patch
@test/markdoc-render-typographer Patch
@test/markdoc-render-with-components Patch
@test/markdoc-render-with-config Patch
@test/markdoc-render-with-extends-components Patch
@test/markdoc-render-with-indented-components Patch
@test/markdoc-render-with-transform Patch
@test/markdoc-variables Patch
@test/content-layer-rendering Patch
@test/mdx-css-head-mdx Patch
@test/image-remark-imgattr Patch
@test/mdx-astro-container-escape Patch
@test/mdx-frontmatter-injection Patch
@test/netlify-skew-protection Patch
@test/netlify-hosted-astro-project Patch
@test/nodejs-api-route Patch
@test/nodejs-badurls Patch
@test/nodejs-encoded Patch
@test/nodejs-errors Patch
@test/nodejs-headers Patch
@test/nodejs-image Patch
@test/locals Patch
@test/node-middleware Patch
@test/nodejs-prerender-404-500 Patch
@test/nodejs-prerender Patch
@test/nodejs-prerendered-error-page-fetch Patch
@test/nodejs-preview-headers Patch
@test/redirects Patch
@test/node-sessions Patch
@test/ssr-assets-middleware Patch
@test/node-static-headers Patch
@test/node-trailingslash Patch
@test/url Patch
@test/well-known-locations Patch
@test/react-component Patch
@test/sitemap-chunks Patch
@test/sitemap-dynamic Patch
@test/sitemap-i18n-fallback Patch
@test/sitemap-ssr Patch
@test/sitemap-static Patch
@test/sitemap-trailing-slash Patch
async-rendering Patch
conditional-rendering Patch
@test/empty-class Patch
svelte-prop-types Patch
@test/astro-vercel-basic Patch
@test/astro-vercel-image Patch
@test/astro-vercel-integration-assets Patch
@test/vercel-isr Patch
@test/vercel-max-duration Patch
@test/vercel-edge-middleware-with-edge-file Patch
@test/vercel-edge-middleware-without-edge-file Patch
@test/astro-vercel-no-output Patch
@test/astro-vercel-prerendered-error-pages Patch
@test/astro-vercel-redirects-serverless Patch
@test/astro-vercel-redirects Patch
@test/vercel-server-islands Patch
@test/astro-vercel-serverless-prerender Patch
@test/astro-vercel-serverless-with-dynamic-routes Patch
@test/astro-vercel-static-assets Patch
@test/vercel-static-headers Patch
@test/astro-vercel-static Patch
@test/vercel-streaming Patch
@test/astro-vercel-with-web-analytics-enabled-output-as-static Patch
vercel-hosted-astro-project Patch
@test/vue-app-entrypoint-async Patch
@test/vue-app-entrypoint-css Patch
@test/vue-app-entrypoint-no-export-default Patch
@test/vue-app-entrypoint-relative Patch
@test/vue-app-entrypoint-src-absolute Patch
@test/vue-app-entrypoint Patch
@test/vue-basics Patch
vue-prop-types Patch
astro-benchmark Patch
@benchmark/adapter Patch
@benchmark/timer Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the pkg: astro Related to the core `astro` package (scope) label Aug 8, 2026
@codspeed

codspeed Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 14.8%

❌ 2 (👁 2) regressed benchmarks
✅ 19 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
👁 Simulation Build: hybrid site (static + server) 1.3 s 1.6 s -17.97%
👁 Simulation Rendering: streaming [true], .md file 1.3 ms 1.4 ms -11.51%

Comparing fetch-refactor-2 (f484912) with main (09f0dc7)

Open in CodSpeed

Comment thread .changeset/fix-dev-hmr-route-updates.md Resolved
Comment thread .changeset/functional-request-core.md Resolved
Rewrites the three changesets to describe user-facing behavior instead of
internals, removes all references to internal planning documents from code
comments, and rewrites comments that described pre-refactor behavior to
describe how the code currently works.
@matthewp matthewp changed the title Internal request refactor Refactor internal request handling into a functional core Aug 10, 2026
Covers the documented advanced pattern from #17591: a custom wrangler
entryfile that builds its own state with `new FetchState(request)` from a
bare workerd request, serves assets through `cf()`, and renders with
`astro(state)`.
The method had no callers — BaseApp.render constructs the FetchState
itself and generated builds only use the fetch member. Also rewrites the
constructor comment to describe the current contract.
@github-actions github-actions Bot added the pkg: integration Related to any renderer integration (scope) label Aug 10, 2026
@matthewp
matthewp marked this pull request as ready for review August 10, 2026 21:51
@florian-lefebvre

Copy link
Copy Markdown
Member

One thing I wanted to do is access the logger outside the request (and the pipeline), for example within getCollection() instead of using console.warn(). Does this PR make it possible/easier?

@ematipico ematipico added pr: astro-review Triggers a bot to do an automated review and removed pr: astro-review Triggers a bot to do an automated review labels Aug 11, 2026
@matthewp matthewp added pr: astro-review Triggers a bot to do an automated review and removed pr: astro-review Triggers a bot to do an automated review labels Aug 11, 2026

@astro-review astro-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a large but well-scoped internal refactor that replaces the monolithic Pipeline and App class hierarchy with a manifest-keyed functional core. The change correctly preserves external API behavior while enabling new FetchState(request) to work inside custom worker entrypoints.

Overall assessment: The implementation is careful and thorough. State is correctly partitioned into per-request (FetchState), per-manifest (createManifestMemo), and per-environment (RenderEnvironment) layers. Backward-compatibility shims (AppPipeline) cover all previously exposed surface area. New unit tests and a Cloudflare integration regression test cover the motivating use case and the new memoization/registry primitives.

Specific notes:

  • The functional error dispatch (renderErrorPage → renderDefaultError / renderDevError / renderBuildError) preserves the old strategy selection.
  • The AppPipeline shim reproduces every old Pipeline member that was reachable from app.pipeline, with identical semantics.
  • Request-reconstruction during rewrites and forwarded-header application correctly drops the removed appSymbol/pipelineSymbol because request-bound state is now captured on FetchState itself.
  • Dev HMR wiring now targets the single per-manifest route table atomically, which fixes the stale-route issue described in one of the changesets.

One actionable issue found: BuildApp inadvertently passes streaming = true into the AppPipeline shim instead of the old manifest.serverLike value, making the backward-compatibility app.pipeline.streaming property incorrect for SSG builds.

This review was made by an LLM. The analysis may be wrong, and reports might be incorrect.

Comment thread packages/astro/src/core/build/app.ts Resolved
@matthewp

Copy link
Copy Markdown
Contributor Author

@florian-lefebvre yes, we can now get a logger keyed by the manifest. I can create a helper for this like we have for actions and some of the other things that hang off of the manifest.

The last surviving Pipeline: app.pipeline was undocumented, so the
stateless compat shim is gone entirely. The node adapter uses the new
public app.getLogger() to wait for the configured log destination, and
BuildApp carries the routeCache/getComponentByRoute accessors StaticPaths
needs across the prerender bundle boundary. The internal PipelineFeatures
bit flags are renamed to FetchFeatures, and @astrojs/node now requires
the astro version that ships app.getLogger().
Replaces resolveLoggerDestination's hand-rolled WeakMap with a
getResolvedLogger accessor built on the shared async manifest memo. The
derivation never rejects: a custom log destination that fails to load is
reported through the console logger and the request proceeds, instead of
failing the first request.

@ematipico ematipico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the explanation!

@ematipico ematipico added pr: astro-review Triggers a bot to do an automated review and removed pr: astro-review Triggers a bot to do an automated review labels Aug 13, 2026
@astro-review astro-review Bot removed the pr: astro-review Triggers a bot to do an automated review label Aug 13, 2026

@astro-review astro-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Large internal refactor that replaces Pipeline/App god-objects with a manifest-keyed functional core. The refactor preserves public adapter APIs, keeps changesets for all user-facing surfaces, and includes good regression coverage.

I found no required blockers. A few optional notes:

  • The dev and container getModuleForRoute implementations drift from the production one (no i18n fallback / static redirect-route replacement) despite comments claiming they are identical.
  • vite-plugin-app/environment.ts imports routeIsRedirect but does not use it.
  • BaseApp.setFetchHandler uses instanceof DefaultFetchHandler, which would misclassify a user handler that legitimately extends that class.

Validation: strictly static; no project code, tests, builds, or checks were run. git fetch origin main could not be executed because git is not available in this environment, so the review is based on the GitHub-provided PR diff and head files.

Changesets: present and cover astro, @astrojs/node, and the three fix/refactor behaviors.

Additional findings

[optional][design]: setFetchHandler uses instanceof DefaultFetchHandler to detect custom handlers

packages/astro/src/core/app/base.ts:222 RIGHT

BaseApp.setFetchHandler sets #hasCustomFetchHandler based on !(handler instanceof DefaultFetchHandler). A user-defined handler that legitimately extends DefaultFetchHandler would be classified as the default, causing BaseApp.render to take the fast path and bypass the custom fetch method. Consider using the existing isDefaultFetchHandler marker (already emitted by the virtual fetchable module) or an explicit property check instead of instanceof.

This review was made by an LLM. The analysis may be wrong, and reports might be incorrect.

getDebugInfo: () => Promise<string>;
}

// Identical to the production implementation: redirect + i18n-fallback

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional][maintainability]: Dev and container getModuleForRoute duplicate production logic incompletely

The production environment's getModuleForRoute normalizes static redirect routes (route.redirectRoute) and replaces i18n fallback routes (routeIsFallback) before looking them up in pageMap. The runnable dev (vite-plugin-app/environment.ts:54-84), non-runnable dev (core/environment/dev-nonrunnable.ts:41-57), and container (container/environment.ts:29-59) implementations only check route.type === 'redirect' and do not handle fallback replacement, yet their comments claim they are 'identical to the production implementation'. If a dev request matches an i18n fallback route, or a container rewrite lands on one, the pageMap lookup uses the fallback RouteData directly and can throw. Centralize the redirect/fallback normalization in a shared helper, or update the comments to note the intentional divergence.

import { RedirectComponentInstance, RedirectSinglePageBuiltModule } from '../core/redirects/index.js';
import { loadRenderer } from '../core/render/index.js';
import { getDefaultRoutes } from '../core/routing/default.js';
import { routeIsRedirect } from '../core/routing/helpers.js';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional][maintainability]: Unused routeIsRedirect import in runnable dev environment

routeIsRedirect is imported at line 14, but getModuleForRoute at line 68 uses route.type === 'redirect' instead. Removing the unused import avoids confusion and tooling noise.

@matthewp
matthewp merged commit 51723b1 into main Aug 13, 2026
47 of 48 checks passed
@matthewp
matthewp deleted the fetch-refactor-2 branch August 13, 2026 20:54
@astrobot-houston astrobot-houston mentioned this pull request Aug 13, 2026
dadezzz pushed a commit to dadezzz/university_notes that referenced this pull request Aug 22, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [@astrojs/markdown-remark](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/markdown/remark)) | [`7.2.2` → `7.2.3`](https://renovatebot.com/diffs/npm/@astrojs%2fmarkdown-remark/7.2.2/7.2.3) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@astrojs%2fmarkdown-remark/7.2.3?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@astrojs%2fmarkdown-remark/7.2.2/7.2.3?slim=true) |
| [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`7.2.2` → `7.2.3`](https://renovatebot.com/diffs/npm/astro/7.2.2/7.2.3) | ![age](https://developer.mend.io/api/mc/badges/age/npm/astro/7.2.3?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/astro/7.2.2/7.2.3?slim=true) |

---

### Release Notes

<details>
<summary>withastro/astro (@&#8203;astrojs/markdown-remark)</summary>

### [`v7.2.3`](https://github.com/withastro/astro/blob/HEAD/packages/markdown/remark/CHANGELOG.md#723)

[Compare Source](https://github.com/withastro/astro/compare/@astrojs/[email protected]...@astrojs/[email protected])

##### Patch Changes

- Updated dependencies \[[`8c193f6`](withastro/astro@8c193f6)]:
  - [@&#8203;astrojs/internal-helpers](https://github.com/astrojs/internal-helpers)@&#8203;0.10.3

</details>

<details>
<summary>withastro/astro (astro)</summary>

### [`v7.2.3`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#723)

[Compare Source](https://github.com/withastro/astro/compare/[email protected]@7.2.3)

##### Patch Changes

- [#&#8203;17724](withastro/astro#17724) [`97140b2`](withastro/astro@97140b2) Thanks [@&#8203;ematipico](https://github.com/ematipico)! - Fixes an issue where Astro could run out of memory when `experimental.collectionStorage` is set to `chunked` and there are multiple concurrent updates to the same collection.

- [#&#8203;17636](withastro/astro#17636) [`51723b1`](withastro/astro@51723b1) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes the dev server sometimes matching against stale routes after pages were added, removed, or renamed, requiring a dev server restart to pick up the change

- [#&#8203;17636](withastro/astro#17636) [`51723b1`](withastro/astro@51723b1) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes the composable request helpers (`astro/fetch`) throwing an error when used on a request that had been rewritten with `Astro.rewrite()` or `next()`

- [#&#8203;17636](withastro/astro#17636) [`51723b1`](withastro/astro@51723b1) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Refactors Astro's internal server-side request handling. This is an internal change: all documented public APIs, including `App` and `NodeApp`, keep their existing signatures and behavior.

  The undocumented internal `app.pipeline` property and the `AppPipeline` export from `astro/app` have been removed. Adapters that used `app.pipeline.getLogger()` to wait for the configured log destination can call the new `app.getLogger()` instead.

  As a result of this refactor, `new FetchState(request)` from `astro/fetch` now works anywhere inside a built Astro server — including custom `src/fetch.ts` entrypoints — without the request needing to first pass through `app.render()`. Previously this threw an error, breaking patterns like the Cloudflare adapter's advanced custom-worker setup.

- [#&#8203;17723](withastro/astro#17723) [`c3b9aed`](withastro/astro@c3b9aed) Thanks [@&#8203;florian-lefebvre](https://github.com/florian-lefebvre)! - Fixes a link in font providers JSDoc annotations

- [#&#8203;17699](withastro/astro#17699) [`e28d227`](withastro/astro@e28d227) Thanks [@&#8203;ArmandPhilippot](https://github.com/ArmandPhilippot)! - Fixes several documentation issues related to the JSDoc for configuration options.

  - When hovering over the `server` and `fonts` options, the JSDoc for the nested options was displayed instead of the JSDoc for the top-level property.
  - Two i18n configuration options were being used incorrectly in the examples.
  - The indentation of some code blocks was broken on hover.

- [#&#8203;17572](withastro/astro#17572) [`2066f39`](withastro/astro@2066f39) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes a crash when a request arrives with a malformed port in the `Host` header (for example `example.com:65536` or `example.com:8080:8080`). Such a host made the constructed request URL invalid, and the fallback that was meant to recover reused the same invalid host and threw again. The request URL now degrades to a host the server controls when the incoming host cannot be parsed, so the request is handled instead of erroring.

- [#&#8203;17685](withastro/astro#17685) [`9f15609`](withastro/astro@9f15609) Thanks [@&#8203;astrobot-houston](https://github.com/astrobot-houston)! - Fixes a dev server error where an SSR full reload triggered by a third-party Vite plugin (such as `@tailwindcss/vite`) could fail with `Failed to load url astro:server-app.js`

- [#&#8203;17636](withastro/astro#17636) [`51723b1`](withastro/astro@51723b1) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Improves error handling for custom log destinations. When the configured logger fails to load, Astro now reports the error and continues with the default console logger instead of failing the first request.

- [#&#8203;17631](withastro/astro#17631) [`cf29bec`](withastro/astro@cf29bec) Thanks [@&#8203;matthewp](https://github.com/matthewp)! - Fixes `getCollection()` and `getEntry()` throwing `DataCloneError` when a collection schema transform returns a `Temporal.PlainDate` or other class instance.

- Updated dependencies \[[`8c193f6`](withastro/astro@8c193f6)]:
  - [@&#8203;astrojs/internal-helpers](https://github.com/astrojs/internal-helpers)@&#8203;0.10.3
  - [@&#8203;astrojs/markdown-remark](https://github.com/astrojs/markdown-remark)@&#8203;7.2.3
  - [@&#8203;astrojs/markdown-satteri](https://github.com/astrojs/markdown-satteri)@&#8203;0.3.6

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4zMS4wIiwidXBkYXRlZEluVmVyIjoiNDQuMzEuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs pr pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom worker entrypoint returns 500: FetchState(request) called on a request without an attached app

3 participants