-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Which Cloudflare product(s) does this pertain to?
Miniflare
What version(s) of the tool(s) are you using?
miniflare@3.20240129.2
What version of Node are you using?
20.11.1
What operating system and version are you using?
Linux 6.7 Arch Linux
Describe the Bug
Observed behavior
It appears that redirect response (e.g. 302 status) causes Error: redirect count exceeded regardless of location header.
Expected behavior
Preferably it returns response from worker script as is with 30x status and location header, instead of internally undici resolving redirection. I think this is preferred if framework author wants to run their server code on Miniflare by proxying request via dispatchFetch.
Steps to reproduce
I added a reproduction in this repository https://github.com/hi-ogawa/reproductions/tree/main/miniflare-redirect Please let me know if it is concise enough.
(additional context)
I'm currently testing running ViteRuntime to run Vite framework server side code inside Workerd/Miniflare. Here a few relevant links:
- Stabilizing `ViteRuntime` vitejs/vite#15774
- https://github.com/hi-ogawa/vite-plugins/tree/main/packages/vite-node-miniflare
- https://github.com/hi-ogawa/vite-runtime-workerd-examples/tree/main/examples/react-router-ssr-data-router
It's mostly working, but I just noticed that react-router/remix's server side redirection isn't working and it appears that it's hitting this bug/limitation of Miniflare.dispatchFetch.
Please provide a link to a minimal reproduction
https://github.com/hi-ogawa/reproductions/tree/main/miniflare-redirect
Please provide any relevant error logs
I also wrote this in readme of the reproduction repo, but I'll copy-paste it here:
Reveal log
$ node main.js https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
[workerd] request.url = https://example.local/redirect
/home/hiroshi/code/personal/reproductions/miniflare-redirect/node_modules/.pnpm/undici@5.28.3/node_modules/undici/index.js:112
Error.captureStackTrace(err, this)
^
TypeError: fetch failed
at fetch (/home/hiroshi/code/personal/reproductions/miniflare-redirect/node_modules/.pnpm/undici@5.28.3/node_modules/undici/index.js:112:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async fetch2 (/home/hiroshi/code/personal/reproductions/miniflare-redirect/node_modules/.pnpm/miniflare@3.20240129.2/node_modules/miniflare/dist/src/index.js:4128:20)
at async Miniflare.dispatchFetch (/home/hiroshi/code/personal/reproductions/miniflare-redirect/node_modules/.pnpm/miniflare@3.20240129.2/node_modules/miniflare/dist/src/index.js:8617:22)
at async file:///home/hiroshi/code/personal/reproductions/miniflare-redirect/main.js:22:18 {
cause: Error: redirect count exceeded
at makeNetworkError (/home/hiroshi/code/personal/reproductions/miniflare-redirect/node_modules/.pnpm/undici@5.28.3/node_modules/undici/lib/fetch/response.js:352:9)
at httpRedirectFetch (/home/hiroshi/code/personal/reproductions/miniflare-redirect/node_modules/.pnpm/undici@5.28.3/node_modules/undici/lib/fetch/index.js:1141:28)
at httpFetch (/home/hiroshi/code/personal/reproductions/miniflare-redirect/node_modules/.pnpm/undici@5.28.3/node_modules/undici/lib/fetch/index.js:1090:24)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /home/hiroshi/code/personal/reproductions/miniflare-redirect/node_modules/.pnpm/undici@5.28.3/node_modules/undici/lib/fetch/index.js:600:16
at async mainFetch (/home/hiroshi/code/personal/reproductions/miniflare-redirect/node_modules/.pnpm/undici@5.28.3/node_modules/undici/lib/fetch/index.js:584:16)
at async httpFetch (/home/hiroshi/code/personal/reproductions/miniflare-redirect/node_modules/.pnpm/undici@5.28.3/node_modules/undici/lib/fetch/index.js:1090:18)
at async /home/hiroshi/code/personal/reproductions/miniflare-redirect/node_modules/.pnpm/undici@5.28.3/node_modules/undici/lib/fetch/index.js:600:16
at async mainFetch (/home/hiroshi/code/personal/reproductions/miniflare-redirect/node_modules/.pnpm/undici@5.28.3/node_modules/undici/lib/fetch/index.js:584:16)
at async httpFetch (/home/hiroshi/code/personal/reproductions/miniflare-redirect/node_modules/.pnpm/undici@5.28.3/node_modules/undici/lib/fetch/index.js:1090:18)
}