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 regression]TypeError: data.hasOwnProperty is not a function #434

Closed
pun-ky opened this issue Nov 24, 2021 · 12 comments
Closed

[Cypress regression]TypeError: data.hasOwnProperty is not a function #434

pun-ky opened this issue Nov 24, 2021 · 12 comments

Comments

@pun-ky
Copy link

pun-ky commented Nov 24, 2021

The problem

After adding line to cypress/support/index.js:

import '@percy/cypress';

then running Cypress fails with:

 Product Page
TypeError: data.hasOwnProperty is not a function
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:39:22)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:32:26)
    at Object.deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:16:17)
    at Encoder.encodeAsBinary (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/index.js:80:41)
    at Encoder.encode (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/index.js:42:29)
    at Client._packet (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io/dist/client.js:169:44)
    at Socket.packet (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io/dist/socket.js:160:21)
    at /Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io/dist/socket.js:274:18
    at /Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/socket-base.js:318:28
    at tryCatcher (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:725:18)
    at _drainQueueStep (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (node:internal/timers:464:21)

TypeError: data.hasOwnProperty is not a function
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:39:22)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:40:32)
    at _deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:32:26)
    at Object.deconstructPacket (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/binary.js:16:17)
    at Encoder.encodeAsBinary (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/index.js:80:41)
    at Encoder.encode (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io-parser/dist/index.js:42:29)
    at Client._packet (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io/dist/client.js:169:44)
    at Socket.packet (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io/dist/socket.js:160:21)
    at /Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/socket/node_modules/socket.io/dist/socket.js:274:18
    at /Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/socket-base.js:318:28
    at tryCatcher (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:725:18)
    at _drainQueueStep (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/krystian.panek/Library/Caches/Cypress/9.1.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (node:internal/timers:464:21)

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

When I am downgrading cypress to:

    "cypress": "^8.7.0",

There is no error. Everything works properly.

Environment

  "devDependencies": {
    "cypress": "^9.1.0",
    "mocha": "^9.1.3",
    "mochawesome": "^7.0.1",
    "cypress-mochawesome-reporter": "^2.3.0",
    "cypress-multi-reporters": "^1.5.0",
    "mocha-junit-reporter": "^2.0.2",
    "typescript": "4.5.2",
    "@percy/cli": "^1.0.0-beta.70",
    "@percy/cypress": "^3.1.1"
  }
  • Node version: 16 LTS
  • MaxOS BigSur
@cexbrayat
Copy link

Just ran into the same issue. Note that it works with Cypress v9.0, but not with v9.1

@Robdel12
Copy link
Contributor

Robdel12 commented Nov 24, 2021

👋🏼 I'm not at my computer to debug this yet but it feels like a red herring that there's nothing Percy related in that stack trace. Why is there bluebird in the stack trace (really old promise dep)? 🤨

I see "typescript": "4.5.2", in your provided packag.json. Given the example app works fine with Cypress v9, I suspect this is actually a typescript + Cypress problem (and maybe + Percy too, there's also this annoying TS bug: #430)

@cexbrayat
Copy link

@Robdel12 This appears to be related to percy: if I remove all the related code to percy, it works fine again in my case (on several projects). We do use TS as well, both TS 4.4 and TS 4.5.

@Robdel12 Robdel12 changed the title Incompatible with Cypress 9.x TypeScript bundling issue (TypeError: data.hasOwnProperty is not a function) Nov 24, 2021
@Robdel12
Copy link
Contributor

This sure does smell a lot like cypress-io/cypress#15101 & #325

@cexbrayat
Copy link

It does. I also had that issue in the past, but this was fixed and had not happened again since.

@cexbrayat
Copy link

FYI someone opened a similar issue on Cypress cypress-io/cypress#19091

@atmullan
Copy link

Also getting this issue after upgrade to 9.1.0, I have percy enabled.

@atmullan
Copy link

Downgrading to Cypress 9.0.0 Resolves the issue for me. Note: Not using Typescript

@geoffharcourt
Copy link

We're seeing error this happen, but only in specs that have involve @percy/cypress, and only as of Cypress 9.1.

@Robdel12 Robdel12 changed the title TypeScript bundling issue (TypeError: data.hasOwnProperty is not a function) [Cypress regression]TypeError: data.hasOwnProperty is not a function Nov 26, 2021
@Robdel12
Copy link
Contributor

My guess is Cypress had a regression in their networking stack. Percy's SDK POST's the DOM snapshot to local Percy server and this was an issue in Cypress in the past (with almost the exact same error message). People are reporting seeing the same issue without Percy and the stack trace doesn't have any Percy code in it.

Looks like we'll have to wait for Cypress to patch

@Robdel12
Copy link
Contributor

Robdel12 commented Dec 2, 2021

I added a comment to the Cypress issue, but this doesn't appear to be a Percy issue. Staying on v9.0.x will stay away from the issue (I believe) while this is looked at by the Cypress folks. Here's the comment I left on their issue:

I spent some time digging in to try and isolate & reproduce.

describe("Breaking reproduction", function () {
  it("doesn't throw an error when making requests", function () {
    cy.then(() =>
      Cypress.backend("http:request", {
        url: "http:localhost:8001/nothing/here",
        method: "POST",
      })
    );
  });
});

This will break with the same stack trace in the OP (https://github.com/percy/example-percy-cypress/runs/4400801282?check_suite_focus=true)

@Robdel12
Copy link
Contributor

Robdel12 commented Dec 6, 2021

Upgrading to v9.1.1 of cypress should solve this cypress-io/cypress#19091

@Robdel12 Robdel12 closed this as completed Dec 7, 2021
esetnik added a commit to esetnik/percy-cypress that referenced this issue Dec 8, 2021
Warn users when using percy-cypress along with known incompatible cypress v9.1.0 

See:
percy#437 (comment)
percy#434
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants