remix icon indicating copy to clipboard operation
remix copied to clipboard

Deffered API (fullstack remix) - AbortController is not defined at new DeferredData

Open cliffordfajardo opened this issue 2 years ago • 6 comments
trafficstars

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

  1. 🚧 Download the stackblitz to your local computer (it doesn't crash on stackblitz)
  2. Visit the /about route & the page will throw an Application Error

CleanShot 2022-11-23 at 18 17 18@2x

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

cliffordfajardo avatar Nov 24 '22 02:11 cliffordfajardo

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

cliffordfajardo avatar Nov 24 '22 02:11 cliffordfajardo

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 avatar Nov 24 '22 02:11 cliffordfajardo

@cliffordfajardo now that defer is officially out, is this still happening? 🙏🏼

machour avatar Jan 22 '23 14:01 machour

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

cliffordfajardo avatar Jan 22 '23 15:01 cliffordfajardo

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.

machour avatar Jan 22 '23 15:01 machour

Sounds good I'll put a PR up to update the docs up today - thanks!

cliffordfajardo avatar Jan 22 '23 16:01 cliffordfajardo

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 avatar Aug 07 '23 18:08 jacob-ebey

@jacob-ebey V1 minimum Node version is 14

MichaelDeBoey avatar Aug 07 '23 18:08 MichaelDeBoey