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

"TypeError: testcase.testcase[0]._attr.time.toFixed is not a function" error happens often in CI pipeline #18970

Closed
ryanborhoo opened this issue Nov 18, 2021 · 32 comments · Fixed by #24218

Comments

@ryanborhoo
Copy link

Current behavior

Getting below errors when running Cypress tests in CircleCI. This issues happens randomly, not able to reproduce on local environment.

TypeError: testcase.testcase[0]._attr.time.toFixed is not a function
    at /home/circleci/.cache/Cypress/8.4.1/Cypress/resources/app/packages/server/node_modules/mocha-junit-reporter/index.js:411:73
    at Array.forEach (<anonymous>:null:null)
    at /home/circleci/.cache/Cypress/8.4.1/Cypress/resources/app/packages/server/node_modules/mocha-junit-reporter/index.js:405:12
    at Array.forEach (<anonymous>:null:null)
    at MochaJUnitReporter.getXml (/home/circleci/.cache/Cypress/8.4.1/Cypress/resources/app/packages/server/node_modules/mocha-junit-reporter/index.js:392:14)
    at MochaJUnitReporter.flush (/home/circleci/.cache/Cypress/8.4.1/Cypress/resources/app/packages/server/node_modules/mocha-junit-reporter/index.js:370:20)
    at MochaJUnitReporter.<anonymous> (/home/circleci/.cache/Cypress/8.4.1/Cypress/resources/app/packages/server/node_modules/mocha-junit-reporter/index.js:247:10)
    at Runner.emit (events.js:315:20)
    at Reporter.emit (/home/circleci/.cache/Cypress/8.4.1/Cypress/resources/app/packages/server/lib/reporter.js:333:46)
    at ProjectBase.<anonymous> (/home/circleci/.cache/Cypress/8.4.1/Cypress/resources/app/packages/server/lib/project-base.js:455:34)
    at Generator.next (<anonymous>:null:null)
    at /home/circleci/.cache/Cypress/8.4.1/Cypress/resources/app/packages/server/node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>:null:null)
    at Object.__awaiter (/home/circleci/.cache/Cypress/8.4.1/Cypress/resources/app/packages/server/node_modules/tslib/tslib.js:113:16)
    at Object.onMocha (/home/circleci/.cache/Cypress/8.4.1/Cypress/resources/app/packages/server/lib/project-base.js:448:51)
    at Socket.<anonymous> (/home/circleci/.cache/Cypress/8.4.1/Cypress/resources/app/packages/server/lib/socket-base.js:213:40)
    at Socket.emit (events.js:315:20)
    at Socket.emitUntyped (/home/circleci/.cache/Cypress/8.4.1/Cypress/resources/app/packages/socket/node_modules/socket.io/dist/typed-events.js:69:22)
    at /home/circleci/.cache/Cypress/8.4.1/Cypress/resources/app/packages/socket/node_modules/socket.io/dist/socket.js:428:39
    at processTicksAndRejections (internal/process/task_queues.js:75:11)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Exited with code exit status 1
CircleCI received exit code 1

Desired behavior

Cypress test run should be either pass or fail.

Test code to reproduce

Test code are saved in private repo, not able to share with Cypress team.

Cypress Version

8.4.1

Other

No response

@conversayShawn
Copy link

Requesting additional information via Support ticket.

@tkharuk
Copy link

tkharuk commented Dec 7, 2021

Can not express how annoying this is, especially for repos with tests that take long to run just to fail like this.

Happens both on 8.3 and 9.1 versions

@halfninja
Copy link

We've seen this in 9.5.2 - it just happened once, with no code changes, and then passed after that. Feels like a bug in mocha-junit-reporter - in various places it assigns ._attr.time to a number or a string, so seems almost inevitable that sometimes it might try to call .toFixed on a string. Maybe worth raising this bug (or a PR) in that project to look at splitting those attrs into two or at least doing a typeof check.

@ryanborhoo
Copy link
Author

@halfninja This issue can be fixed if you turn on the debugging mode in Cypress. I was trying to report this as a bug to Cypress, but the issue is gone whenever I turn on the debugging mode.

@DamienCassou
Copy link

I can reproduce on Cypress 10.3.1.

@DamienCassou
Copy link

@ryanborhoo said:

This issue can be fixed if you turn on the debugging mode in Cypress

what do you mean by "debugging mode"?

@ryanborhoo
Copy link
Author

@DamienCassou If you are running Cypress in continue integration environment you will use command line to run your test, such as yarn cypress run. The "debugging mode" means you enable the debugging functionality by telling cypress show all the log info. Example: NO_COLOR=1 DEBUG=cypress:* yarn cypress run.

@halfninja
Copy link

Looking at the reporter source code, I think it would only run over this code twice (causing it to call .toFixed(3) on something that is already a string) if the runner emits the end event twice, as that's the only time it would go through this code. Can anyone see if there's a situation where the Cypress runner might do this?

@halfninja
Copy link

I've raised a PR in the reporter to make it a bit more resilient: michaelleeallen/mocha-junit-reporter#172

@halfninja
Copy link

Should be fixed in mocha-junit-reporter 2.1.0

michaelleeallen/mocha-junit-reporter#172 (comment)

@troygibb
Copy link

troygibb commented Oct 4, 2022

I'm also seeing the mocha-junit-reporter fixed on the cypress side here. Any idea when cypress will coordinate a new release with the fix?

@marktnoonan
Copy link
Contributor

@troygibb this should be included in next week's release. Thanks @halfninja for getting this into the reporter!

@troygibb
Copy link

thanks @marktnoonan! great to see fixes coming in so quick

I don't see this fix mentioned in the release notes here: https://docs.cypress.io/guides/references/changelog#10-10-0. Any chance you can comment?

@marktnoonan
Copy link
Contributor

marktnoonan commented Oct 11, 2022

I'm not sure we typically list a dependency version bump in the changelog, @astone123 do you think it's worth adding this one, since it lets us close this issue?

The 10.10.0 was cut this morning and includes the latest code from develop, so it will include that version bump to 2.1.0 for mocha-junit-reporter.

@astone123
Copy link
Contributor

@marktnoonan I made a PR to add this dependency update to the changelog cypress-io/cypress-documentation#4776

@troygibb can you try out v10.10.0 and verify that the update fixed this issue so that we can close this out? Thanks!

@troygibb
Copy link

will do! thank you all

@gmanriqueUy
Copy link

gmanriqueUy commented Oct 11, 2022

It seems the server package is still using the old version of mocha-junit-reporter in current develop (at the time of writing this comment).

@Incarnation
Copy link

Incarnation commented Oct 11, 2022

@astone123 @marktnoonan
can we have it ready for the next release? is it in 2 week? or can we have a hot-fix for this one?

image

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: backlog labels Oct 12, 2022
@Turbotailz
Copy link
Contributor

My apologies... I totally missed it in the server package :( PR has been raised to fix it.

@albinohrn
Copy link

We would really appreciate a patch-release containing this fix since it breaks a large portion of our CI jobs. 🙏

@marktnoonan
Copy link
Contributor

marktnoonan commented Oct 12, 2022

I'll make a branch that does what @Turbotailz's newest PR (#24218) does, and then build a pre-release version of Cypress with the change included. You will be able to point your Cypress version to that pre-release build @albinohrn, so you can validate that it actually fixes the problem, and be unblocked.

Then we can include the version bump in the next regular release of Cypress in about 2 weeks (or in a patch in-between, if there is one).

When the pre-release build is completed I'll update this thread.

@albinohrn
Copy link

That would be great, thanks @marktnoonan!

@marktnoonan
Copy link
Contributor

Alright, builds are ready, for simplicity I am consolidating things in this comment so people don't have to go digging around:

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Here are the build install instructions per platform:

linux x64: npm install https://cdn.cypress.io/beta/npm/10.10.1/linux-x64/martnoonan/mocha-junit-reporter-bump-b6331ca237a6ed6c708c51193f5f10605b45b3e0/cypress.tgz

linux arm64: npm install https://cdn.cypress.io/beta/npm/10.10.1/linux-arm64/martnoonan/mocha-junit-reporter-bump-b6331ca237a6ed6c708c51193f5f10605b45b3e0/cypress.tgz

darwin x64: npm install https://cdn.cypress.io/beta/npm/10.10.1/darwin-x64/martnoonan/mocha-junit-reporter-bump-b6331ca237a6ed6c708c51193f5f10605b45b3e0/cypress.tgz

win32 x64: npm install https://cdn.cypress.io/beta/npm/10.10.1/win32-x64/martnoonan/mocha-junit-reporter-bump-b6331ca237a6ed6c708c51193f5f10605b45b3e0/cypress.tgz

Please grab which ever one you need and let me know if this fixes the issue.

@albinohrn
Copy link

albinohrn commented Oct 12, 2022

Not sure if I'm doing something wrong but I can't get it to work. It seems like there's some urls that would need to be updated.

Installing Cypress (version: https://cdn.cypress.io/beta/binary/10.10.1/darwin-arm64/martnoonan/mocha-junit-reporter-bump-b6331ca237a6ed6c708c51193f5f10605b45b3e0/cypress.zip)

[STARTED] Task without title.
[FAILED] The Cypress App could not be downloaded.
[FAILED]
[FAILED] Does your workplace require a proxy to be used to access the Internet? If so, you must configure the HTTP_PROXY environment variable before downloading Cypress. Read more: https://on.cypress.io/proxy-configuration
[FAILED]
[FAILED] Otherwise, please check network connectivity and try again:
[FAILED]
[FAILED] ----------
[FAILED]
[FAILED] URL: https://cdn.cypress.io/beta/binary/10.10.1/darwin-arm64/martnoonan/mocha-junit-reporter-bump-b6331ca237a6ed6c708c51193f5f10605b45b3e0/cypress.zip
[FAILED] Error: Failed downloading the Cypress binary.
[FAILED] Response code: 404
[FAILED] Response message: Not Found
[FAILED]
[FAILED] ----------
[FAILED]
[FAILED] Platform: darwin-arm64 (21.6.0)
[FAILED] Cypress Version: 10.10.1
The Cypress App could not be downloaded.

Does your workplace require a proxy to be used to access the Internet? If so, you must configure the HTTP_PROXY environment variable before downloading Cypress. Read more: https://on.cypress.io/proxy-configuration

Otherwise, please check network connectivity and try again:

----------

URL: https://cdn.cypress.io/beta/binary/10.10.1/darwin-arm64/martnoonan/mocha-junit-reporter-bump-b6331ca237a6ed6c708c51193f5f10605b45b3e0/cypress.zip
Error: Failed downloading the Cypress binary.
Response code: 404
Response message: Not Found

----------

If I try to access the url in the browser i get a 404 as well but I'm redirected through a client-side redirect to download.cypress.io where the production release is downloaded.

@Incarnation
Copy link

i think you just need to put the URL inside your package.json like
"cypress": "https://cdn.cypress.io/beta/npm/10.10.1/darwin-x64/martnoonan/mocha-junit-reporter-bump-b6331ca237a6ed6c708c51193f5f10605b45b3e0/cypress.tgz",

instead of
"cypress": "10.10.0",

@marktnoonan
Copy link
Contributor

i think you just need to put the URL inside your package.json like "cypress": "https://cdn.cypress.io/beta/npm/10.10.1/darwin-x64/martnoonan/mocha-junit-reporter-bump-b6331ca237a6ed6c708c51193f5f10605b45b3e0/cypress.tgz",

instead of "cypress": "10.10.0",

This is the end result after the npm install so that should work (and lead to the correct result in CI even if locally there are problems installing).

FWIW npm install and download are both working normally for me with that url.

@Incarnation
Copy link

working for me now! thank you for the quick update!
@marktnoonan

@Turbotailz
Copy link
Contributor

I am getting the same 404 error. I will just wait until this is released.

@albinohrn
Copy link

This seems to be an issue with newer Macs running the new architecture. When looking closer on the url I see that I'm trying to access:

https://cdn.cypress.io/beta/binary/10.10.1/darwin-arm64/martnoonan/mocha-junit-reporter-bump-b6331ca237a6ed6c708c51193f5f10605b45b3e0/cypress.zip

vs the npm package

https://cdn.cypress.io/beta/npm/10.10.1/darwin-x64/martnoonan/mocha-junit-reporter-bump-b6331ca237a6ed6c708c51193f5f10605b45b3e0/cypress.tgz

The difference beeing darwin-x64 (in the working npm package) and darwin-arm64 when trying to download the binary. If i replace arm64 with x64 in the binary url the file is found.

@marktnoonan
Copy link
Contributor

Thanks for the feedback folks, I've approved #24218

@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Oct 13, 2022
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 13, 2022

The code for this is done in cypress-io/cypress#24218, 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 Oct 25, 2022

Released in 10.11.0.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Oct 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.