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 can not work with SSE #24284

Open
Hangochung81 opened this issue Oct 18, 2022 · 15 comments
Open

Cypress can not work with SSE #24284

Hangochung81 opened this issue Oct 18, 2022 · 15 comments
Labels
E2E Issue related to end-to-end testing Reproducible Can be reproduced Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: bug

Comments

@Hangochung81
Copy link

Current behavior

image

Cypress can't load a list (list use SSE method). And header of Cypress is removed "origin".

Desired behavior

No response

Test code to reproduce

Use Cypress navigate to: https://console.metaaccess-b.opswat.com/inventory/devices/all to reproduce

Cypress Version

10.9.0

Node version

14.18.1

Operating System

Windows 11

Debug Logs

No response

Other

No response

@warrensplayer
Copy link
Contributor

@Hangochung81 Cypress should support server side events (SSE). Can you please provide a small reproduction repo that shows this problem? I am not able to access the URL provided because it is behind a log in.

Unless we receive a reliable reproduction, we'll eventually have to close this issue until we can reproduce it.

Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide.

@Hangochung81
Copy link
Author

Hangochung81 commented Oct 19, 2022

This is the account which you can use to login to reproduce:

email: [email protected]
password: P@ssw0rd@123

OR the script for reproduce:

describe('Reproduce', () =>{

    it('Reproduce', () =>{

     cy.visit("https://console.metaaccess-b.opswat.com/dashboard/overview")
     cy.xpath(`//input[@data-cy="signin-email-input"]`).type("[email protected]")
     cy.xpath(`//span[contains(text(),"Sign In")]/..`).click()
     cy.xpath(`//input[@data-cy="signin-password-input"]`).type("P@ssw0rd@123")
     cy.xpath(`//span[contains(text(),"Sign In")]/..`).click()
     cy.xpath(`//span[text() = "Inventory"]`).click({force: true})

    })

})

Please have me check, thank you a lot.

@Hangochung81
Copy link
Author

@Hangochung81 Cypress should support server side events (SSE). Can you please provide a small reproduction repo that shows this problem? I am not able to access the URL provided because it is behind a log in.

Unless we receive a reliable reproduction, we'll eventually have to close this issue until we can reproduce it.

Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide.

@warrensplayer Could you reproduce this issue?

@amehta265 amehta265 assigned amehta265 and unassigned warrensplayer Oct 25, 2022
@amehta265
Copy link
Contributor

@Hangochung81 Thank you for providing access to the website as well as the test script for reproduction!
I am able to replicate this error on my end and am hoping to find a solution concerning this as soon as possible. Thank you for your patience.

@Hangochung81
Copy link
Author

@Hangochung81 Thank you for providing access to the website as well as the test script for reproduction! I am able to replicate this error on my end and am hoping to find a solution concerning this as soon as possible. Thank you for your patience.

Thank you so much! please let me know if you need any supporting.

@amehta265
Copy link
Contributor

@Hangochung81 Looks like the issue is stems from the way EventSource communicates with the server to maintain connection. On the Cypress browser, it looks as though in the main.js file the EventSource tries to obtain all the devices for the webpage to load and is successful in doing that. However the EventSource may also be emitting a "heartbeat" to the server to keep the connection alive. This is what may be causing an issue.
This is why you can see the error message in the console where the client side is trying to connect with the server.
Screenshot 2022-11-04 at 12 44 49 PM

Looks like this is an ongoing issue with angular projects that use EventSource: Yaffle/EventSource#143
Yaffle/EventSource#129

As it turns out the "https://console.metaaccess-b.opswat.com/inventory/devices/all" website is also based on an angular project.

Would it be possible to follow some of the options mentioned in the issue above, and not use EventSource to communicate with the server?
I understand that this is still a Cypress related problem as the website works fine on browser but I was just wondering if changing the EventSource was a possibility?

@Hangochung81
Copy link
Author

@Hangochung81 Looks like the issue is stems from the way EventSource communicates with the server to maintain connection. On the Cypress browser, it looks as though in the main.js file the EventSource tries to obtain all the devices for the webpage to load and is successful in doing that. However the EventSource may also be emitting a "heartbeat" to the server to keep the connection alive. This is what may be causing an issue. This is why you can see the error message in the console where the client side is trying to connect with the server. Screenshot 2022-11-04 at 12 44 49 PM

Looks like this is an ongoing issue with angular projects that use EventSource: Yaffle/EventSource#143 Yaffle/EventSource#129

As it turns out the "https://console.metaaccess-b.opswat.com/inventory/devices/all" website is also based on an angular project.

Would it be possible to follow some of the options mentioned in the issue above, and not use EventSource to communicate with the server? I understand that this is still a Cypress related problem as the website works fine on browser but I was just wondering if changing the EventSource was a possibility?

Hi @amehta265 , I have followed some of the options mentioned in the issue above but it doesn't work, when I don't use EventSource, it works (the website can load the list). Since the EventSource in the project can not be removed, do you have any plan in the future to fix this issue?

@amehta265
Copy link
Contributor

Thank you for your response. We are looking into a work around and hopefully should find some resolution soon

@amehta265 amehta265 assigned marktnoonan and unassigned amehta265 Nov 9, 2022
@marktnoonan
Copy link
Contributor

I'm just catch up in this conversation.

Note for those of us working on it: I wonder if it's connected to HTTP/2 support, #3708, based on this warning in the MDN docs for EventSource:

Warning: When not used over HTTP/2, SSE suffers from a limitation to the maximum number of open connections, which can be specially painful when opening various tabs as the limit is per browser and set to a very low number (6). The issue has been marked as "Won't fix" in Chrome and Firefox. This limit is per browser + domain, so that means that you can open 6 SSE connections across all of the tabs to www.example1.com and another 6 SSE connections to www.example2.com. (from Stackoverflow). When using HTTP/2, the maximum number of simultaneous HTTP streams is negotiated between the server and the client (defaults to 100).

Several EventSource issues are mentioned in the comments. Not sure if this specific issue would be fixed by it though.

@marktnoonan
Copy link
Contributor

I'm going to route this to the e2e team, since we have been able to reproduce using the example provided.

@yinshuxun
Copy link

@marktnoonan Sorry to ask,Is there a new progress in this question?

@evgeny-goldin
Copy link

Hi, @marktnoonan, are there any updates available?

@marktnoonan
Copy link
Contributor

Hi folks, I'm afraid I don't have any updates, at this time it has been routed to the correct team, but hasn't been picked up. When it starts to move there will be activity in this issue. I don't have any information on when that might be.

@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
@bluepioupiou
Copy link

Hello, +1 on this issue. I can't find another way to test SSE with Cypress. Any update ?

@jennifer-shehane jennifer-shehane added the Reproducible Can be reproduced label Nov 5, 2024
@VladZapodeanuBe
Copy link

VladZapodeanuBe commented Dec 9, 2024

Cypress can't get data from SSE event to know when something is done and load the page.
Hello. There are another ways to test? Any response is appreciated. Ty!

Cypress Version
13.16.0

Node version
18.14.2

Operating System
Ubuntu 24.04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing Reproducible Can be reproduced Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: bug
Projects
None yet
Development

No branches or pull requests

10 participants