Skip to content

Conversation

@benmccann
Copy link
Member

@benmccann benmccann commented Dec 2, 2023

vitejs/vite#14818 broke a lot of tests. I mostly fixed it here: 43a745a.

I don't know what's causing the remaining failures, but I think it's also something related to the base path - if I remove the base path from the failing tests then they start working. You can reproduce them with:

cd packages/kit/test/apps/options-2
pnpm build
pnpm test:build

When I run pnpm preview in that directory everything seems to work and it looks like started is added to the body, so I don't know why the tests are failing with a timeout looking for started.

@changeset-bot
Copy link

changeset-bot bot commented Dec 2, 2023

⚠️ No Changeset found

Latest commit: da7dba3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@teemingc
Copy link
Member

teemingc commented Dec 2, 2023

The tests are failing because the Vite preview middleware always returns / when making a request to /basepath or /basepath/. This makes it impossible to tell the difference between the two. As a result, the URL getting passed to server.respond is always /basepath/ even when the browser makes a request to /basepath. The server sends a page response instead of a trailing slash redirect, so the browser stays on /basepath while receiving the page for /basepath/

Essentially, the tests get stuck because the browser can't download the scripts while the trailing slash is incorrect and our assets are linked using relative paths. Hence, no started class added to the body element.

Reproduction

  1. Run pnpm build && pnpm preview in packages/kit/test/apps/options-2.
  2. Navigate to http://localhost:4173/basepath.
  3. Open the web inspector console to see the missing asset requests.
  4. Check the HTML source to see the hydration script at the bottom of the body. The relative paths to the assets resolve to http://localhost:4173/_app/... as a result of the missing trailing slash.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants