Skip to content

HMR broken with middleware folder #17039

Description

@lexisother

Astro Info

Astro                    v6.4.6
Node                     v24.14.0
System                   Linux (x64)
Package Manager          pnpm
Output                   server
Adapter                  @astrojs/node
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I'm trying to split my middlewares across multiple files, but HMR stops working for the files in src/middleware/. It works as expected for src/middleware.ts, but that also stops working if it is moved to src/middleware/index.ts.
Smells like a similar issue as the one with actions, unless I'm misinterpreting.

2026-06-10.23-59-13.mp4

What's the expected result?

Files in the src/middleware/ should also trigger HMR.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-e7ndck5e?file=src%2Fmiddleware.ts

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P3: minor bugAn edge case that only affects very specific usage (priority)pkg: astroRelated to the core `astro` package (scope)

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions