-
Notifications
You must be signed in to change notification settings - Fork 47.6k
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
Scheduler's use of SharedArrayBuffer will require cross-origin isolation #20829
Comments
I've created a PR to fix this. #20831 |
Will this be back-ported to React 16? I have projects that can't upgrade yet because they rely on packages that aren't fully compatible with React 17 yet (e.g. Material-UI). |
My workaround is to put a script in the index.html file: <script> if (!crossOriginIsolated) SharedArrayBuffer = ArrayBuffer </script> |
Why is this closed? 😮 just need to publish the solution? |
Because the fix has been merged to master. #20831 |
We don’t generally backport anything except critical security fixes. My understanding is that the only problem here is a warning. Not that something would actually break. Do you have evidence to the contrary? |
Starting Chrome 91, FWIW, you can emulate how it will behave in Chrome by launching it with a command line flag |
React 17.0.2 was released with removed dependency on |
We don't plan to backport this since there is no real breaking change for React here. |
@gaearon For later versions that Fix will not be available? |
You mean for earlier ones? No, but also nothing would break. You can ignore the message. |
This should get rid of sharedArrayBuffer cross-origin warning facebook/react#20829
use http-proxy-middleware package but works only in dev mode, so not in production. I'd suggest using a Nginx as proxy and inject the 2 http headers. |
React version: v17.0.1
Steps To Reproduce
npx create-react-app myapp
cd myapp && npm start
Link to code example: https://react-z95km1.stackblitz.io/
https://stackblitz.com/edit/react-z95km1
The current behavior
Warning:
scheduler.development.js:298 [Deprecation] SharedArrayBuffer will require cross-origin isolation as of M91, around May 2021. See https://developer.chrome.com/blog/enabling-shared-array-buffer/ for more details.
The expected behavior
No warning will be shown.
As the warning shows, Chrome will require cross-origin isolation starting version 91 in order to use SharedArrayBuffer. To enable cross-origin isolation, the page needs to be loaded with COOP and COEP headers which I believe is out of React's control. You can learn more about this at https://developer.chrome.com/blog/enabling-shared-array-buffer/.
As it's confusing for React users to see this warning every time they open the page, I'd propose two things:
self.crossOriginIsolated
boolean flag.The problematic code is here: https://github.com/facebook/react/blob/master/packages/scheduler/src/SchedulerProfiling.js#L21-L22
FWIW, with cross-origin isolation, you'll be able to use JS Self-Profiling API too.
cc: @acomminos @maudnals
The text was updated successfully, but these errors were encountered: