-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throwing AbortController
error every response in the Vite dev server when using Remix, Vite, and Cloudflare
#10014
Comments
Getting this too |
I just started working with Remix + Cloudflare on a prototype and immediately ran into this. |
I can confirm getting this issue too. @caprolactam's theory is correct too. I forked the plugin and removed #9976's changes, and everything works as expected without errors. |
Hello, I am speaking here for the first time, if there is something inappropriate, please let me know in time and thank you. |
@IvorySun Try fixing the version of Remix to {
"dependencies": {
"@remix-run/cloudflare": "2.12.0",
"@remix-run/cloudflare-pages": "2.12.0",
"@remix-run/react": "2.12.0",
},
"devDependencies": {
"@remix-run/dev": "2.12.0",
"@remix-run/server-runtime": "2.12.0",
}
} |
hey @caprolactam I am very happy to see your reply, thank you so much. I will try it as you said. |
Hi @IvorySun the issue you're facing might be more complicated than the bug mentioned in this issue. Unfortunately, I can only provide a workaround related to this bug. Anyway, please double-check the following points. If this doesn't fix it, there might be another problem.
|
Hi @caprolactam I updated and locked the version of the relevant package exactly as you said. But the error still occurs. Thank you very much for your enthusiastic response. Thank you again |
@IvorySun please make sure the dev package 2.12.0 is indeed installed (by inspecting your package manager lock file). You might have to delete your lock file and run a fresh install to do that. I can confirm using 2.12.0 does not cause the issue. |
@bmatzner @caprolactam You are right.
No errors now. |
Getting this on a fresh Cloudflare project as well. Unfortunately pinning cloudflare to |
We are also seeing this behaviour |
Hm - I guess since these aren't actual Node We'll take a look at this, but in the meantime - @Phoenixmatrix since you forked and removed that change - are you able to confirm that with that changes removed, are requests aborted properly on the server during dev when using cloudflare? The easiest way to check this is to set up a export async function loader({ request }: LoaderFunctionArgs) {
request.signal.addEventListener("abort", () => console.log("signal aborted"));
await new Promise((r) => setTimeout(r, 1000));
return { value: Math.random() };
} |
ok this turns out to be a two-fold issue. The tl;dr; is that it will be resolved via #10046 and #10047. The first issue is that our long standing logic for aborting Node requests was slightly flawed. We used to abort requests on the The second half of the issue is that cloudflare/deno It's also worth noting that if you've adopted single fetch, theres a new timeout mechanism for streamed data that you will want to be aware of. |
This is resolved by the above PRs and will be available in the next release |
Reproduction
npx create-remix@latest --template remix-run/remix/templates/cloudflare
remix vite:build
andremix vite:dev
.http://localhost:5173
, then the app throws an error.System Info
Used Package Manager
npm
Expected Behavior
The app should run without this error.
Actual Behavior
Throwing this error every response.
TypeError [ERR_INVALID_STATE]: Invalid state: Controller is already closed at ReadableByteStreamController.close (node:internal/webstreams/readablestream:1156:13) at close (/project/workspace/node_modules/react-dom/cjs/react-dom-server.browser.development.js:143:15) at flushCompletedQueues (/project/workspace/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6906:9) at abort (/project/workspace/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6951:7) at EventTarget.listener (/project/workspace/node_modules/react-dom/cjs/react-dom-server.browser.development.js:7000:9) at [nodejs.internal.kHybridDispatch] (node:internal/event_target:826:20) at EventTarget.dispatchEvent (node:internal/event_target:761:26) at abortSignal (node:internal/abort_controller:371:10) at AbortController.abort (node:internal/abort_controller:393:5) at EventTarget.abort (node:internal/deps/undici/undici:6279:21) { code: 'ERR_INVALID_STATE' }
Note that the app works fine in Wrangler(
wrangler pages dev ./build/client
), but this error occurs when using the Vite dev server. Additionally, this error is thrown when using Remix version is2.12.1
, but not with version2.12.0
. I think the changes in PR #9976 are causing this issue.The text was updated successfully, but these errors were encountered: