Skip to content
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

Cypress 11.2.0: selectFile command to upload a huge sized file is failing in Electron browser but works fine in Chrome and Firefox #24583

Open
DiwanD03 opened this issue Nov 8, 2022 · 9 comments
Labels
browser: electron E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: performance 🏃‍♀️ Performance related

Comments

@DiwanD03
Copy link

DiwanD03 commented Nov 8, 2022

Current behavior

I am trying to upload a large file in a web application using 'selectFile' command in cypress. Though the code works fine in chrome and firefox browser, if I select electron the browser crashes with below error:

[7898:1108/172752.248261:ERROR:node_bindings.cc(143)] Fatal error in V8: v8::ToLocalChecked Empty MaybeLocal.
The Test Runner unexpectedly exited via a exit event with signal SIGSEGV

Desired behavior

The file should get successfully uploaded in electron browser too.

Test code to reproduce

cy.get('').selectFile('', {
force: true,
})

Cypress Version

10.4.0
11.2.0

Node version

v14.18.1

Operating System

macOS 12.6

Debug Logs

No response

Other

No response

@DiwanD03
Copy link
Author

DiwanD03 commented Nov 8, 2022

The file being uploaded is huge in size - 422957367

If I upload a small sized file, it goes through fine in electron browser too.

@DiwanD03 DiwanD03 changed the title Cypress 10.4.0: selectFile command to upload a file in browser is failing in Electron browser but works fine in Chrome and Firefox Cypress 10.4.0: selectFile command to upload a huge sized file is failing in Electron browser but works fine in Chrome and Firefox Nov 8, 2022
@DiwanD03
Copy link
Author

Hi @nagash77, Were you able to make any progress on this issue?
Checking if it is atleast reproducible in your environment.

@DiwanD03
Copy link
Author

Hi @rockindahizzy are there any updates on this issue?

@DiwanD03
Copy link
Author

DiwanD03 commented Dec 6, 2022

Hi @nagash77 , @rockindahizzy please update on the latest status of this issue.

@mike-plummer
Copy link
Contributor

Hi @DiwanD03 , sorry for the delay getting back to you. We've been heads down on the v12 release of Cypress for the last couple weeks.

I will try to carve out time to look into this tomorrow, but in the interim I do want to mention that we had a major upgrade to our bundled Electron in version 10.10.0 of Cypress. I would recommend upgrading to at least that version (or better yet, to v12.0.1 which we released this week) to see if that upgrade fixes your issue. Let me know if you have a chance to try that out

@DiwanD03
Copy link
Author

DiwanD03 commented Dec 8, 2022

Hi @mike-plummer , thank you for taking this up. I did try to test the scenario using version 11.2.0 of Cypress and saw the same error as described earlier.
Do let me know how it goes at your end.

@DiwanD03 DiwanD03 changed the title Cypress 10.4.0: selectFile command to upload a huge sized file is failing in Electron browser but works fine in Chrome and Firefox Cypress: selectFile command to upload a huge sized file is failing in Electron browser but works fine in Chrome and Firefox Dec 8, 2022
@DiwanD03 DiwanD03 changed the title Cypress: selectFile command to upload a huge sized file is failing in Electron browser but works fine in Chrome and Firefox Cypress 11.2.0: selectFile command to upload a huge sized file is failing in Electron browser but works fine in Chrome and Firefox Dec 8, 2022
@mike-plummer
Copy link
Contributor

mike-plummer commented Dec 8, 2022

@DiwanD03 I did some local testing on this and reproduced the issue you've described. After doing a bit of playing around I was able to get a ~400 MB file to work, but a 408 MB file fails, and the tests fail in exactly the same way when run in open mode and headless run mode. This leads me to suspect it's not an inherent "Cypress is doing something wrong in Electron" issue but rather a memory limitation (headless mode should preserve more resources for internals since there's less UI going on). Based on the logging (the V8::ToLocalChecked logs you referenced and that I see as well) I'm inclined to say it's not something we have much control over since that's an internal Electron error, but I can't say that for certain. Electron recently introduced some revisions to their memory architecture (pointer compression and the memory cage, to name two) which have caused a decent number of memory issues throughout the ecosystem.

Do you have a hard requirement to upload a 400+ MB file within an E2E test like this? It sounds like you have a workaround by using Chrome if you absolutely need to validate using the massive file, but could you restructure your test using a smaller file in order to focus your test more on the user interactions in the browser?

Update: To correct my earlier statement, I have learned that this is actually a limitation of how Cypress implements the selectFile command. Our implementation utilizes a WebSocket and marshals and dispatches the entire file in a single request which has a limit on the size of file it can support. In the interests of transparency, I'm happy to send this along to the team but it's unlikely to be prioritized in the near future since uploading a 400+ MB file is a somewhat uncommon use case.

@DiwanD03
Copy link
Author

DiwanD03 commented Dec 9, 2022

@mike-plummer I understand now, that it's a known limitation and as you mentioned we have a workaround(using chrome) in place. Thank you for looking into this, for the detailed explanation and for re-routing it to your team for further action.

@nagash77 nagash77 added E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. and removed routed-to-e2e labels Apr 19, 2023
@vvip-68
Copy link

vvip-68 commented Oct 10, 2023

Hi, all. I quite necessary to upload file about 400M (currently - 396M), but selectFile() crashes cypress app with message
"Cannot create a string longer than 0x1fffffe8 characters;
Error: Cannot create a string longer than 0x1fffffe8 characters"

I test webUI of my device that must accept firmware package, update and restart device with new firmware and I got error above on any browser - Chrome / FireFox / Electron.

When I put file and upload it manually all works correctly.
As I understand HTML5 element do not load whole file into memory and sends content of file by chunks.
So why selectFile() trying to load whole content of file as is, and if take in attention error message and stack - as base64 coded string?

Cannot create a string longer than 0x1fffffe8 characters
Error: Cannot create a string longer than 0x1fffffe8 characters
at Object.slice (node:buffer:655:37)
at Buffer.toString (node:buffer:825:14)
at i (:4457:67003)
at s.exports (:4457:67130)
at :4457:68422
at Array.forEach ()
at Object.encodePayload (:4457:68405)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser: electron E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: performance 🏃‍♀️ Performance related
Projects
None yet
Development

No branches or pull requests

6 participants