Skip to content

Comments

fix: race condition in resolvedPathname#15506

Draft
ascorbic wants to merge 3 commits intomainfrom
resolve-path-race
Draft

fix: race condition in resolvedPathname#15506
ascorbic wants to merge 3 commits intomainfrom
resolve-path-race

Conversation

@ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Feb 13, 2026

Changes

Fixes a race condition in the dev server that could cause TypeError: Missing parameter errors when handling concurrent requests to dynamic routes.

resolvedPathname (the pathname after .html stripping in route matching) was stored as shared instance state on AstroServerApp and DevApp. Concurrent requests could overwrite each other's value, causing a mismatch between the matched route and the pathname used to extract params.

This PR threads resolvedPathname through RenderOptions as a local value per-request instead:

  • Adds resolvedPathname to the RenderOptions interface
  • AstroServerApp.handleRequest passes it from devMatch to render()
  • BaseApp.render() uses it from options when provided, or captures it from devMatch when doing its own route matching
  • Removes the createRenderContext overrides that injected the pathname from instance state

Testing

Added a unit test that fires concurrent requests to dynamic routes and verifies params are resolved independently.

Docs

N/A - bug fix only

@changeset-bot
Copy link

changeset-bot bot commented Feb 13, 2026

🦋 Changeset detected

Latest commit: 9f9edc5

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

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 Feb 13, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 13, 2026

Merging this PR will not alter performance

✅ 9 untouched benchmarks


Comparing resolve-path-race (063bbdc) with main (d789452)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (00e95c4) during the generation of this report, so d789452 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@ascorbic ascorbic marked this pull request as draft February 13, 2026 20:30
@ascorbic ascorbic force-pushed the resolve-path-race branch 4 times, most recently from 0b2f538 to ae7db87 Compare February 19, 2026 22:38
Thread resolvedPathname through RenderOptions instead of storing it
as shared instance state on DevApp/AstroServerApp.
@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

1 participant