Cypress: Cannot read property isAttached of undefined

Created on 23 Mar 2020  ·  13Comments  ·  Source: cypress-io/cypress

Current behavior:

Cypress does NOT work for Firefox 75.

  1) Receiving a project-message "before each" hook for "when multiple tabs are open":
     TypeError: Cannot read property 'isAttached' of undefined

Because this error occurred during a 'before each' hook we are skipping the remaining tests in the current suite: 'Receiving a project-message'
      at /home/etiennebruines/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/lib/browsers/firefox-util.js:98:20
      at tryCatcher (/home/etiennebruines/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
      at /home/etiennebruines/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/method.js:15:34
      at /home/etiennebruines/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/lib/browsers/firefox-util.js:227:40
      at tryCatcher (/home/etiennebruines/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/home/etiennebruines/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/home/etiennebruines/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromise0 (/home/etiennebruines/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:649:10)
      at Promise._settlePromises (/home/etiennebruines/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:729:18)
      at _drainQueueStep (/home/etiennebruines/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:93:12)
      at _drainQueue (/home/etiennebruines/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/home/etiennebruines/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (/home/etiennebruines/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14)
      at processImmediate (internal/timers.js:439:21)

Desired behavior:

No errors.

Test code to reproduce

Any test consisting of more than one it-clause. Firefox crashes upon GC collection afterwards.

Currently there's no Firefox 75-Cypress-docker image available yet, so no forked test was linked.

Example:

/// <reference types="cypress" />
describe('page', () => {
  it('works', () => {
    cy.visit('https://example.cypress.io')
  })
  it('still works', () => {
    cy.visit('https://example.cypress.io')
  })
})

Versions

  │ Cypress:    4.2.0                                                                             
  │ Browser:    Custom Firefox Developer Edition 75 (headless)       
 OS: Linux-based
firefox existing workaround bug v4.0.2

Most helpful comment

Yes, I can confirm this is happening

  • ❗️Fails in Firefox Develop Edition 75.0b7.
  • ✅Passes in Firefox 72.0.2
  • ❗️Fails during cypress run (headless or headed) - notably this is because runMode auomatically has gcInterval set.
  • ✅Passes during cypress open
  • ❗️Fails when visiting a URL
  • ✅Passes with standard expect assertion without cy.visit()
  • ↺ Test just hangs forever in Cypress 4.0.0-4.0.1
  • ❗️Fails in Cypress 4.0.2+

The error is throwing here:

https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/browsers/firefox-util.ts#L57:L57

Full callstack

TypeError: Cannot read property 'isAttached' of undefined
    at /Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/firefox-util.js:98:20
    at tryCatcher (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at /Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/method.js:15:34
    at /Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/firefox-util.js:227:40
    at tryCatcher (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:439:21)

Workaround

You can set firefoxGcInterval to null for runMode. Note this may have other unintended consequences. Please see our full explanation of firefoxGcInterval here: https://on.cypress.io/configuration#firefoxGcInterval

In configuration file - aka cypress.json

{
  "firefoxGcInterval": {
    "runMode": null,
    "openMode": null
  }
}

Edited by @jennifer-shehane - removed "firefoxGcInterval": null workaround.

All 13 comments

Yes, I can confirm this is happening

  • ❗️Fails in Firefox Develop Edition 75.0b7.
  • ✅Passes in Firefox 72.0.2
  • ❗️Fails during cypress run (headless or headed) - notably this is because runMode auomatically has gcInterval set.
  • ✅Passes during cypress open
  • ❗️Fails when visiting a URL
  • ✅Passes with standard expect assertion without cy.visit()
  • ↺ Test just hangs forever in Cypress 4.0.0-4.0.1
  • ❗️Fails in Cypress 4.0.2+

The error is throwing here:

https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/browsers/firefox-util.ts#L57:L57

Full callstack

TypeError: Cannot read property 'isAttached' of undefined
    at /Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/firefox-util.js:98:20
    at tryCatcher (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at /Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/method.js:15:34
    at /Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/firefox-util.js:227:40
    at tryCatcher (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/jennifer/Library/Caches/Cypress/4.2.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:439:21)

Workaround

You can set firefoxGcInterval to null for runMode. Note this may have other unintended consequences. Please see our full explanation of firefoxGcInterval here: https://on.cypress.io/configuration#firefoxGcInterval

In configuration file - aka cypress.json

{
  "firefoxGcInterval": {
    "runMode": null,
    "openMode": null
  }
}

Edited by @jennifer-shehane - removed "firefoxGcInterval": null workaround.

Regarding the workaround:

"firefoxGcInterval": null gave me:

TypeError: intervals is null
 Because this error occurred during a 'before each' hook we are skipping the remaining tests in the current suite: 'Test reset password'
   createIntervalGetter/<@http://localhost/__cypress/runner/cypress_runner.js:145972:22
   install/<@http://localhost/__cypress/runner/cypress_runner.js:145995:30
   listener@http://localhost/__cypress/runner/cypress_runner.js:138840:19
   tryCatcher@http://localhost/__cypress/runner/cypress_runner.js:165465:23
   ./node_modules/bluebird/js/release/map.js/module.exports/MappingPromiseArray.prototype._promiseFulfilled@http://localhost/__cypress/runner/cypress_runner.js:162586:38
   ./node_modules/bluebird/js/release/promise_array.js/module.exports/PromiseArray.prototype._iterate@http://localhost/__cypress/runner/cypress_runner.js:163787:31
   init@http://localhost/__cypress/runner/cypress_runner.js:163751:10
   ./node_modules/bluebird/js/release/map.js/module.exports/MappingPromiseArray.prototype._asyncInit@http://localhost/__cypress/runner/cypress_runner.js:162555:10
   ./node_modules/bluebird/js/release/async.js/</Async.prototype._drainQueue@http://localhost/__cypress/runner/cypress_runner.js:160195:12
   ./node_modules/bluebird/js/release/async.js/</Async.prototype._drainQueues@http://localhost/__cypress/runner/cypress_runner.js:160200:10
   Async/this.drainQueues@http://localhost/__cypress/runner/cypress_runner.js:160074:14

This one does seem to have the desired effect, not throwing any other errors:
```
{
"firefoxGcInterval": {
"runMode": null,
"openMode": null
}
}
````

oh, you're right. This is what I get for not running all the code I pasted 😅 Will update my comment and see if this is a separate issue.

Opened an issue here for firefoxGcInterval: null not being supported https://github.com/cypress-io/cypress/issues/6825

Trying the workaround posted seems to allow me to complete one test but then fails immediately after

Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:201:27)
 {
  errno: 'ECONNRESET',
  code: 'ECONNRESET',
  syscall: 'read'
}
Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:201:27)`

Cypress: 4.8.0 │
│ Browser: Firefox 77 (headless)`

Trying the workaround posted seems to allow me to complete one test but then fails immediately after

Error: read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:201:27) { errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' } Error: read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:201:27)

Cypress: 4.8.0 │ │ Browser: Firefox 77 (headless)

How do you set Firefox to headless?
Do the tests run without the headless ?

@jpita pass --headless to the command line to run as headless

According to https://github.com/cypress-io/cypress/issues/6813#issuecomment-603066124 it does not run headed (not-headless) either.

@jpita pass --headless to the command line to run as headless

According to #6813 (comment) it does not run headed (not-headless) either.

both work fine for me on 4.8.0

The same error started to happen in GitHub actions 2~3 weeks ago. Before it was running fine. I do not know what changed (same Firefox version, same Cypress version and same commit in my codebase suddenly stopped working).

--headless is not an option for me because I use Cypress to test an extension.

Fortunately "runMode": null fixed my problem for now.

The error persists in Cypress version 4.9.0 in combination with docker image cypress/browsers:node12.14.1-chrome83-ff77

The code for this is done in cypress-io/cypress#7791, but has yet to be released.

We'll update this issue and reference the changelog when it's released.

The work for this has been moved to https://github.com/cypress-io/cypress/pull/8040 in order to get our pre-5.0 release.

Released in 4.11.0.

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

Was this page helpful?
0 / 5 - 0 ratings