← 输入框|github.com|刷新
Skip to content

vite dev server: /ns/m doesn't decode percent-encoded filenames (bracketed route files 404) #11455

Closed

Description

@aleclarson

Summary

In dev-session (HTTP ESM) mode, modules fetched through the /ns/m/* endpoint 404 when the on-disk filename contains characters that the device's HTTP layer percent-encodes — e.g. [ and ] used by file-based router params (app/demo/[id].tsrx).

The same file serves fine when requested with raw (unencoded) brackets, so the lookup is using the encoded path literally instead of decoding it first.

Repro

  1. Any app with a source file containing brackets (a router dynamic segment such as src/app/demo/[id].tsrx).
  2. ns run ios (dev server on :5173).
  3. Compare:
    • curl --globoff 'http://localhost:5173/ns/m/packages/app/src/app/demo/[id].tsrx' → 200
    • curl 'http://localhost:5173/ns/m/packages/app/src/app/demo/%5Bid%5D.tsrx' → 404

Observed

Device boot log at app launch:

NativeScript: module graph walk missed http://<host>:5173/ns/m/packages/app/src/app/demo/[id].tsrx?import — falling back to a blocking synchronous fetch. This should not happen; please report it.
Dynamic import error: Error: Instantiation failed (http-loader): http://<host>:5173/ns/m/src/index.ts — Uncaught Error: HTTP import failed: http://<host>:5173/ns/m/packages/app/src/app/demo/[id].tsrx?import (status=404)
[ns-entry] deterministic dev session bootstrap failed Error: Instantiation failed ...

The dev session still boots and HMR works, so it's non-fatal — but the lazy/prefetched route module never loads (and the log says 'should not happen').

Expected

/ns/m decodes req.url (decodeURIComponent on the pathname) before resolving it to a filesystem path, so encoded and raw spellings hit the same module.

Environment

  • @nativescript/vite via ns 9.1.1 / @nativescript/core 9.1.2
  • vite 8.3.0 (rolldown)
  • iOS simulator, macOS
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