Skip to content

Conversation

@hi-ogawa
Copy link
Owner

@hi-ogawa hi-ogawa commented Feb 8, 2025

todo

  • test dev
  • test build
  • test hmr

notes

Our virtual css request is getting stuck http://localhost:5173/@id/__x00__virtual:dev-ssr-css.css?direct

image

This can be reproduced with curl:

# it doesn't get stuck if virtual css is requested first.
$ curl -v 'http://localhost:5173'
... ok ...

$ curl -v 'http://localhost:5173/@id/__x00__virtual:dev-ssr-css.css?direct'
* Host localhost:5173 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:5173...
* Connected to localhost (::1) port 5173
* using HTTP/1.x
> GET /@id/__x00__virtual:dev-ssr-css.css?direct HTTP/1.1
> Host: localhost:5173
> User-Agent: curl/8.11.1
> Accept: */*
> 
* Request completely sent off

It looks like this transformRequest is stuck when /app/styles.css?direct

const res = await server.transformRequest(url + "?direct");


It's likely a dead lock of ViteDevServer.waitForRequestsIdle of multiple "css root files", which relies on the following heuristics isPotentialCssRootFile. Probably there's something odd with having both virtual:dev-ssr-css.css and /app/styles.css.

https://github.com/tailwindlabs/tailwindcss/blob/d684733d804a0b8951d13c94fe27350271e076b6/packages/%40tailwindcss-vite/src/index.ts#L313-L322


Since virtual:dev-ssr-css.css is only to proxy styles from server to client, it is legitimate to skip it from tailwind processing since /app/styles.css is the original one tailwind can process. Is there a way to let tailwind skip our virtual?

@@ -0,0 +1,7 @@
diff --git a/dist/index.mjs b/dist/index.mjs
Copy link
Owner Author

Choose a reason for hiding this comment

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

Since xxx.css and xxx.css?direct seem to also get in dead lock, we might need to add ?direct

https://github.com/tailwindlabs/tailwindcss/blob/7d51e38d8c4a5cba20face7384be9629c9dcc3c8/packages/%40tailwindcss-vite/src/index.ts#L10

- const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/
+ const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url|direct)\b/

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.

(core) support tailwind v4 vite plugin

2 participants