cypress: (uncaught exception) ReferenceError: SharedArrayBuffer is not defined in Electron Browser after Update to 8.6.0
Current behavior
After the Update from 8.5.0 to 8.6.0 I get the following error while starting my app in the Electron browser:
Uncaught (in promise) ReferenceError: SharedArrayBuffer is not defined
The problem might be the new Electron version, but until now I was not able to find the root cause. An other Cypress user reported a similar problem on Stackoverflow: https://stackoverflow.com/questions/70794396/sharedarraybuffer-not-defined-when-using-cypress/70863376#70863376
Desired behavior
The app should start normally without the SharedArrayBuffer error.
Test code to reproduce
Here ist a simple Code Repo to reproduce the error: https://github.com/unlocomqx/cypress-ffmpeg
Switch the Cypress version to 8.5.0 and start the test with the Electron browser. -> It should work fine Switch the Cypress version to 8.6.0 or higher and start the test with the Electron browser. -> The SharedArrayBuffer error occurs.
Cypress Version
8.6.0 and higher
Other
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 8
- Comments: 15
Any update on this? I’m evaluating Cypress expressly for Web Worker e2e tests for
SharedArrayBufferfunctionality and not being able to control the “root” page cross origin restriction headers makes it so thatcrossOriginIsolatedis always false.To emphasize the state I’m seeing: the iFrame receives the appropriate headers, but the root Cypress context outside the iFrame does not. AFAICT, the embedding context must have these headers set for
SharedArrayBufferto be available.Dear Cypress team We encounter the same situation in our projects. It’s getting more and more painful to be stuck with an old Cypress version (8.5.0). We kindly ask you to give this issue a higher priority since the solution is already mentioned in the comments above. Thank you!
@unlocomqx I tested it locally by setting the headers in serve-base.ts as mentioned above in the following file: “C:\Users{USERNAME}\AppData\Local\Cypress\Cache\8.6.0\Cypress\resources\app\packages\server\lib\server-base.js” And the result was as expected. If the top level request returns the COEP and the COOP headers, it works:
@tbiethman, @jennifer-shehane or who else is able to fix this. Could you please fix this. Thanks.
I’ve got an update on this. As a workaround, we use the Chrome Browser, and start it with this argument:
--enable-features=SharedArrayBuffer. (For more information how to launch browsers with argument in Cypress see: https://docs.cypress.io/api/plugins/browser-launch-api#Modify-browser-launch-arguments)This allows us to go catch up to the newest Cypress version.
Anyway, for Electron the problem is still present. I didn’t found any way to tell Electron to enable SharedArrayBuffers. Except by adding the required CORS headers to the Cypress Server, as mentioned: https://github.com/cypress-io/cypress/issues/19912#issuecomment-1024276051