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

Tests sometimes failing with a JSON.parse error #27555

Closed
Gamer1120 opened this issue Aug 15, 2023 · 9 comments
Closed

Tests sometimes failing with a JSON.parse error #27555

Gamer1120 opened this issue Aug 15, 2023 · 9 comments
Labels
stale no activity on this issue for a long period

Comments

@Gamer1120
Copy link

Current behavior

When I run my Cypress tests in Chrome headed, there is no issue, either via cypress open or cypress run --headed. However, when I try to run them headlessly, sometimes they fail with a JSON parse error. The position in the JSON parse error can change with the error. I'm on Windows 10. It could happen at any time during test execution (my test lasts 2-3 minutes). I used yarn upgrade to upgrade my dependencies, but it's still happening. The application I'm testing is very old (e.g. uses iframes inside of frames). I think there might be a communication issue with the headless browser. I installed Ubuntu as a VM on this machine and ran the same tests, and the issue occurred there as well. I have no clue where to start debugging. How would I even debug this?

`

DevTools listening on ws://127.0.0.1:61099/devtools/browser/f1c85310-d86a-4c6f-84c2-bd6586fbce7a
Missing baseUrl in compilerOptions. tsconfig-paths will be skipped

====================================================================================================

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 12.17.3 │
│ Browser: Chrome 115 (headless) │
│ Node Version: v20.5.0 (C:\Program Files\nodejs\node.exe) │
│ Specs: 1 found (initial-setup.cy.ts) │
│ Searched: C:\dev**\cypress\e2e\initial-setup.cy.ts │
└────────────────────────────────────────────────────────────────────────────────────────────────┘

────────────────────────────────────────────────────────────────────────────────────────────────────

Running: initial-setup.cy.ts (1 of 1)

Setup system from empty database
√ should allow creating a new user role (40816ms)
Expected ',' or '}' after property value in JSON at position 11572
SyntaxError: Expected ',' or '}' after property value in JSON at position 11572
at JSON.parse ()
at A. (:2385:521659)
at A.emit (node:events:527:28)
at g.U (:2385:506953)
at g.emit (node:events:527:28)
at g.dataMessage (:2385:487328)
at :2385:486860
at :2385:478182
at :2385:479134
at afterWrite (node:internal/streams/writable:497:5)
at onwrite (node:internal/streams/writable:477:7)
at Zlib.cb (node:internal/streams/transform:202:7)
at Zlib.processCallback (node:zlib:611:8)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
`

Desired behavior

Continue the test and not throw the JSON parse error

Test code to reproduce

I can't provide this.

Cypress package version: 12.17.3
Cypress binary version: 12.17.3
Electron version: 21.0.0
Bundled Node version:
16.16.0

Cypress Version

12.17.3

Node version

16.16.0

Operating System

Windows 10

Debug Logs

I can't provide all logs, due to this being an internal application. Is there any way to censor the logs? Are the logs needed to start debugging?

Other

I'm more than happy to help debug this issue, I just have no clue where to start.

@Farhaz12
Copy link

Farhaz12 commented Aug 15, 2023

experiencing same issue.
Cypress version: 12.17.2

Error log:
Expected ',' or '}' after property value in JSON at position 539
SyntaxError: Expected ',' or '}' after property value in JSON at position 539
at JSON.parse ()
at A. (:2404:525293)
at A.emit (node:events:527:28)
at g.U (:2404:510587)
at g.emit (node:events:527:28)
at g.dataMessage (:2404:490962)
at :2404:490494
at :2404:481816
at :2404:482768
at afterWrite (node:internal/streams/writable:497:5)
at onwrite (node:internal/streams/writable:477:7)
at Zlib.cb (node:internal/streams/transform:202:7)
at Zlib.processCallback (node:zlib:611:8)
The Test Runner unexpectedly exited via a exit event with signal SIGABRT

@Gamer1120
Copy link
Author

It also happens in 12.16.0. Downgrading to 12.1.0 appears to have fixed the issue. I hope to be able to debug which version is causing this in about 2 weeks, since I'm not developing tests next week.

@Gamer1120
Copy link
Author

I've tried different versions today.

Does not happen on 12.1.0 

Does not happen on 12.8.1 

Does not happen on 12.12.0 

Does not happen on 12.14.0 

Happens on 12.15.0 

It looks like this is your first time using Cypress: 12.15.0 

  

√  Verified Cypress! C:\Users\xxx\AppData\Local\Cypress\Cache\12.15.0\Cypress 

  

Opening Cypress... 



  

DevTools listening on ws://127.0.0.1:53221/devtools/browser/d2497257-b661-4918-a595-4381db41f5d2 

Missing baseUrl in compilerOptions. tsconfig-paths will be skipped 

  

==================================================================================================== 

  

  (Run Starting) 

  

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ 

  │ Cypress:        12.15.0                                                                        │ 

  │ Browser:        Chrome 115 (headless)                                                          │ 

  │ Node Version:   v20.5.0 (C:\Program Files\nodejs\node.exe)                                     │ 

  │ Specs:          1 found (initial-setup.cy.ts)                                                  │ 

  │ Searched:       C:\xxx\cypress\e2e\initial-setup.cy.ts                        │ 

  └────────────────────────────────────────────────────────────────────────────────────────────────┘ 

  

  

──────────────────────────────────────────────────────────────────────────────────────────────────── 

  

  Running:  initial-setup.cy.ts                                                             (1 of 1) 

  

  

  Setup system from empty database 

Unterminated string in JSON at position 1185 

SyntaxError: Unterminated string in JSON at position 1185 

    at JSON.parse (<anonymous>) 

    at A.<anonymous> (<embedded>:2404:525293) 

    at A.emit (node:events:527:28) 

    at g.U (<embedded>:2404:510587) 

    at g.emit (node:events:527:28) 

    at g.dataMessage (<embedded>:2404:490962) 

    at <embedded>:2404:490494 

    at <embedded>:2404:481816 

    at <embedded>:2404:482768 

    at afterWrite (node:internal/streams/writable:497:5) 

    at onwrite (node:internal/streams/writable:477:7) 

    at Zlib.cb (node:internal/streams/transform:202:7) 

    at Zlib.processCallback (node:zlib:611:8) 

error Command failed with exit code 1. 

info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. 

Happens on 12.16.0 

Happens on 12.17.3 

It appears that a regression has occurred in 12.15.0. Looking at the release notes for that version, I'd suspect that this is the cause:

  • Added support for running Cypress tests with Chrome's new --headless=new flag. Chrome versions 112 and above will now be run in the headless mode that matches the headed browser implementation.

I'll downgrade to 12.14.0 for now, and I hope someone else finds the time to debug the issue and fix it.

@scopsy
Copy link

scopsy commented Aug 24, 2023

It also happened to us :( Downgrading didn't help, unfortunately. Considering disabling cypress cloud dashboard parallelization now, because usually when re running a failed action, it works. So we are considering a possibility with some issues on the cypress cloud side.

After disabling cypress cloud, the tests are passing consistently.

@Gamer1120
Copy link
Author

This issue doesn't happen anymore in 13.2.0 for me, so it might have gotten fixed somewhere inbetween.

@Gamer1120
Copy link
Author

@scopsy Could you upgrade to 13.2.0 and see if it still happens for you?

@Ismael-B
Copy link

Ismael-B commented Dec 4, 2023

What helped me with this issue was double checking the GitHub actions secret. After editing mine to the correct format, I was able to get it running with no issues.

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Jun 2, 2024
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale no activity on this issue for a long period
Projects
None yet
Development

No branches or pull requests

5 participants