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

Fixture files defined in cy.route with fx and fixture shortcut take longer to load, sometimes timeout. #8181

Closed
SurjithP opened this issue Aug 5, 2020 · 11 comments · Fixed by #8215
Labels
type: regression A bug that didn't appear until a specific Cy version release v4.12.0 🐛 Issue present since 4.12.0

Comments

@SurjithP
Copy link

SurjithP commented Aug 5, 2020

Current behavior:

cy.route('GET', `**/test/**`, `fixture:test.json`).as('something');

error :

Error:    CypressError: `cy.fixture()` timed out waiting `30000ms` to receive a fixture. No fixture was ever sent by the server.Desired behavior: the file is in the fixture folder and it should be taken, this was working in 4.11.0 Versions The issue is newer version 4.12.0
@SurjithP SurjithP changed the title Issue with fixture in cy.route command URGENT : Issue with fixture in cy.route command Aug 5, 2020
@jennifer-shehane
Copy link
Member

The code around the fixture shortcut was updated in 4.12.0, so that it should now throw a descriptive error if the file specified is not found in the location given - this would be unexpected behavior if this other error is being shown. #7818

I'm not able to reproduce this behavior from the information given. Please provide a repo or more code to reproduce the issue. Maybe it is dependent on the content in your json file - or if you have a cy.wait() later defined waiting on the alias. We'd love to fix this if there's a regression.

My code that does not fail

cypress/integration/spec.js

it('test', () => {
  cy.server()
  cy.route('GET', `**/test/**`, `fixture:test.json`).as('something')
})

it('test2', () => {
  cy.visit('https://example.cypress.io/commands/files')
  cy.server()
  cy.route('GET', 'comments/*', 'fixture:test.json').as('getComment')
  cy.get('.fixture-btn').click()
  cy.wait('@getComment')
})

cypress/fixtures/test.json

{}

Screen Shot 2020-08-05 at 1 22 06 PM

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Aug 5, 2020
@SurjithP
Copy link
Author

SurjithP commented Aug 5, 2020

@jennifer-shehane
If this was my code issue, how that worked in 4.11.0 and earlier versions. Json file is the fixture folder and content is same as before. nothing was changed, but after the cypress update it started failing
image
image

Console error :
image

@jennifer-shehane
Copy link
Member

Yes, I believe that you may be encountering an error in 4.12.0. I need the exact code to run to reproduce it - as shown above, I'm not able to reproduce with the information given alone.

The cy.route() command does not log to the Command Log in the Test Runner, but I see in your screenshot that this is logging. Have you overwritten the cy.route() command somewhere in your project using Cypress.Commands.overwrite?

Please provide a full example so that we can begin work on fixing the issue. We will have to close this issue without this - since we will not have a path to move forward.

@SurjithP
Copy link
Author

SurjithP commented Aug 5, 2020

@jennifer-shehane , I can understand, but I can't provide my repo details to you. we do not overwrite any inbuild cypress commands, only our custom things are doing like that.
I just tried the same test in version 4.11.o Its green
image
image

in 4.12.0 , test failing in this line
image

@jennifer-shehane
Copy link
Member

You'll need to revert to Cypress 4.11.0 for now then.

Unfortunately we can't work on fixing this possible regression without a clear example given on how to reproduce the issue.

@SurjithP
Copy link
Author

SurjithP commented Aug 5, 2020

@jennifer-shehane , Ok. One doubt , is there is any file size limit or any new json validation added in version 4.12.0 ?
my file is little lengthy

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Aug 5, 2020

How large is your file? I tried this with a 1,400kb JSON file and it is not erroring with my example above.

Are you positive that this fixture file exists? Previously, in 4.11.0, this would silently pass - not warning you that the file does not exist. We fixed this error, but it should show a better error than you're seeing if that is the case.

@SurjithP
Copy link
Author

SurjithP commented Aug 5, 2020

@jennifer-shehane it was a file size issue, my file was the size of more than 8MB. Removed some content in the file, now it works. Can you please provide the max file size?

@jennifer-shehane
Copy link
Member

I am able to recreate this sometimes with a JSON file that is 11mb in size. Sometimes it takes longer than 30seconds to load. I can recreate this below - with a lower timeout.

it('test', () => {
  cy.server()
  Cypress.config('responseTimeout', 5000)
  cy.route('GET', 'test', 'fixture:large_11mb.json')
})

You could increase the global responseTimeout to increase the time allowed to fetch this fixture, but since this is increasing the runtime it'd probably be best to just downgrade to 4.11.0.

This issue was introduced in 4.12.0. When downgrading - the file instantly resolves.

4.11.0

Only took 0.02 seconds to run test

Screen Shot 2020-08-06 at 4 48 59 PM

4.12.0

Takes longer than 10 seconds, sometimes longer than 30 seconds (which is default timeout).

Screen Shot 2020-08-06 at 4 51 19 PM

@jennifer-shehane jennifer-shehane added the type: regression A bug that didn't appear until a specific Cy version release label Aug 6, 2020
@cypress-bot cypress-bot bot added stage: ready for work The issue is reproducible and in scope and removed stage: needs information Not enough info to reproduce the issue labels Aug 6, 2020
@jennifer-shehane jennifer-shehane changed the title URGENT : Issue with fixture in cy.route command Fixture files defined in cy.route with fx and fixture shortcut take longer to load, sometimes timeout. Aug 6, 2020
@jennifer-shehane jennifer-shehane added the v4.12.0 🐛 Issue present since 4.12.0 label Aug 6, 2020
@cypress-bot cypress-bot bot added stage: work in progress and removed stage: ready for work The issue is reproducible and in scope labels Aug 7, 2020
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Aug 10, 2020
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Aug 10, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 10, 2020

The code for this is done in cypress-io/cypress#8215, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 20, 2020

Released in 5.0.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v5.0.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Aug 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: regression A bug that didn't appear until a specific Cy version release v4.12.0 🐛 Issue present since 4.12.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants