remix
remix copied to clipboard
Deffered API (fullstack remix) - AbortController is not defined at new DeferredData
What version of Remix are you using?
- deferred (beta)
Can someone else download the stackblitz code (click the cloud icon in the top right to download) and see if this code crashes for you? Stabkblitz URL: https://stackblitz.com/edit/node-qbt8d7
"@remix-run/node": "deferred",
"@remix-run/react": "deferred",
"@remix-run/serve": "deferred",
"@remix-run/dev": "deferred",
Steps to Reproduce
- 🚧 Download the stackblitz to your local computer (it doesn't crash on stackblitz)
- Visit the
/aboutroute & the page will throw an Application Error

ReferenceError: AbortController is not defined at new DeferredData (/Users/cfajardo/Repos/deferred-bug_abort_controller/node_modules/@remix-run/deferred/dist/index.js:28:27) at loader (/Users/cfajardo/Repos/deferred-bug_abort_controller/node_modules/@remix-run/server-runtime/dist/responses.js:46:61) at loader (/Users/cfajardo/Repos/deferred-bug_abort_controller/app/routes/index.tsx:1:1) at Object.callRouteLoader (/Users/cfajardo/Repos/deferred-bug_abort_controller/node_modules/@remix-run/server-runtime/dist/data.js:78:20) at /Users/cfajardo/Repos/deferred-bug_abort_controller/node_modules/@remix-run/server-runtime/dist/server.js:262:113 at Array.map (anonymous)) at handleDocumentRequest (/Users/cfajardo/Repos/deferred-bug_abort_controller/node_modules/@remix-run/server-runtime/dist/server.js:262:67) at requestHandler (/Users/cfajardo/Repos/deferred-bug_abort_controller/node_modules/@remix-run/server-runtime/dist/server.js:50:24) at /Users/cfajardo/Repos/deferred-bug_abort_controller/node_modules/@remix-run/express/dist/server.js:39:28 at /Users/cfajardo/Repos/deferred-bug_abort_controller/node_modules/@remix-run/serve/dist/index.js:48:
Machine specs
- Macbook Pro Intel 2019
- Browser: Google Chrome
Stabkblitz URL ( 🚧 download code locally to see error)
- https://stackblitz.com/edit/node-qbt8d7
Expected Behavior
Page should not crash
Actual Behavior
Page is crashing
References
- https://github.com/remix-run/remix/pull/3434
Found the issue
I ran this code on an older version of node on my work computer. It was using node v14.15.4 which doesn't have AbortController in the runtime; Upgrading up, fixed the issue
Followups
I think we should update the engines property on all packages so people don't run into this; currently the engine is at "node": ">=14"
@MichaelDeBoey any thoughts on this?
References
- AbortController was introduced in node v15.0 https://nodejs.medium.com/node-js-v15-0-0-is-here-deb00750f278
The challenge is ESlint has a several hard coded engine version(s) still 😢 So if I wanted to run put the engine to node 15, eslint would error during install & leave a bad DX for users installing Remix
https://github.com/eslint/eslint/blob/main/package.json#L164
Ahh brings back memories to https://github.com/remix-run/remix/issues/3652
@cliffordfajardo now that defer is officially out, is this still happening? 🙏🏼
i found out it wasnt really a problem with defer The abort controller error happened because I was using node version < 15
Since defer uses AbortController, I think maybe remix should have a minimum node version of 15 now?
What do you think?
"engines": {
"node": "^>= 15.0.0"
}
MDN - abort controller (end of link shows node 15 for AbortController release date) https://developer.mozilla.org/en-US/docs/Web/API/AbortController
Thank you for your feedback.
I don't think we should update our requirements, since someone may not be using defer and still want to be on node14. Same reasoning for not requiring React 18, which is also required for defer.
We may want to add a note on the Streaming guide tho.
Sounds good I'll put a PR up to update the docs up today - thanks!
Minimum required node version is 16, and that includes AbortController. Currently it's pollyfilled for 15 users, but that will be removed in the next major as the minimum node version will be 18 starting at v2.
@jacob-ebey V1 minimum Node version is 14