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

Warning: .then() only accepts functions but was passed: [object Undefined] when running Cypress in Docker #15281

Closed
blomqma opened this issue Mar 2, 2021 · 13 comments · Fixed by #16277
Assignees
Labels
type: unexpected behavior User expected result, but got another v6.5.0 🐛 Issue present since 6.5.0

Comments

@blomqma
Copy link

blomqma commented Mar 2, 2021

Current behavior

So when running Cypress inside a Docker container with node:15.10.0-buster-slim image and all the required runtime dependencies from cypress/base Docker image, the terminal will be full of the following output on literally every test case.

Screenshot 2021-03-02 at 10 28 29

Desired behavior

Obviously, no such output should exist.

Test code to reproduce

I doubt this has nothing to do with the syntax of my test cases themselves, the error reproduces on every test with even empty contents so anything can be used - I think it's related to the node version somehow.

Versions

Cypress: 6.5.0
Docker image: node:15.10.0-buster-slim

@jennifer-shehane
Copy link
Member

Can you provide a reproducible example? This is likely dependent on the project you are running - can you provide a repo? Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Mar 2, 2021
@jennifer-shehane
Copy link
Member

I couldn't recreate this running Node 15.10.0 with a sample project.

@pmerwin
Copy link

pmerwin commented Mar 3, 2021

I see this output in our github actions running on Ubuntu: latest: with node 12

    (node:2795) Warning: .then() only accepts functions but was passed: [object Undefined]
(node:2795) Warning: .then() only accepts functions but was passed: [object Undefined]

(node:2262) Warning: a promise was created in a handler at internal/timers.js:456:21 but was not returned from it, see http://goo.gl/rRqMUw
    at Function.Promise.cast (/home/runner/.cache/Cypress/6.6.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:225:13)

@pmerwin
Copy link

pmerwin commented Mar 3, 2021

@jennifer-shehane I believe to reproduce you can create a github workflow with cypress-io/github-action@v2

@kkaarreell
Copy link

kkaarreell commented Mar 5, 2021

I am seeing similar problem on RHEL container. The issue appeared after a cypress update. The traceback looks as follows

(node:8997) Warning: .then() only accepts functions but was passed: [object Undefined]
    at Object.wrapChildPromise (/home/travis/.cache/Cypress/6.6.0/Cypress/resources/app/packages/server/lib/plugins/util.js:42:8)
    at Object.wrap (/home/travis/.cache/Cypress/6.6.0/Cypress/resources/app/packages/server/lib/plugins/child/task.js:53:8)
    at execute (/home/travis/.cache/Cypress/6.6.0/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:127:19)
    at EventEmitter.<anonymous> (/home/travis/.cache/Cypress/6.6.0/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:202:5)
    at EventEmitter.emit (events.js:315:20)
    at process.<anonymous> (/home/travis/.cache/Cypress/6.6.0/Cypress/resources/app/packages/server/lib/plugins/util.js:19:22)
    at process.emit (events.js:315:20)
    at emit (internal/child_process.js:903:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)

@kkaarreell
Copy link

kkaarreell commented Mar 5, 2021

Not an expert but to me it seems that wrapChildPromise is not getting the cb parameter.

  wrapChildPromise (ipc, invoke, ids, args = [], cb) {
    return Promise.try(() => {
      return invoke(ids.eventId, args)
    }).then(cb)
$ pwd
/home/testuser/.cache/Cypress/6.6.0/Cypress/resources/app/packages/server
$ grep -R wrapChildPromise
lib/plugins/util.js:  wrapChildPromise (ipc, invoke, ids, args = [], cb) {
lib/plugins/child/browser_launch.js:    util.wrapChildPromise(ipc, invoke, ids, args)
lib/plugins/child/dev-server.js:  util.wrapChildPromise(ipc, invoke, ids, [options])
lib/plugins/child/preprocessor.js:  util.wrapChildPromise(ipc, invoke, ids, [childFile])
lib/plugins/child/run_plugins.js:  const wrapChildPromise = () => {
lib/plugins/child/run_plugins.js:    util.wrapChildPromise(ipc, invoke, ids, args)
lib/plugins/child/run_plugins.js:      return wrapChildPromise()
lib/plugins/child/task.js:  util.wrapChildPromise(ipc, invoke, ids)
lib/plugins/child/task.js:  util.wrapChildPromise(ipc, invoke, ids)
lib/plugins/child/task.js:  util.wrapChildPromise(ipc, invoke, ids, [arg])

@jweingarten
Copy link

Same problem here ... since 6.5.0 upgrade.

@kkaarreell
Copy link

Hi @jennifer-shehane , may I ask for a review? I believe the root cause is clear now and the fix should be also simple (e.g. define a default callback function for the cb parameter or just check it is not undefined before calling it).

@joelgrimberg
Copy link

same issue here, without running in Docker.. I will try to setup an example-repo

@jahusa02
Copy link

I have exactly the same problem with the cypress/base:10 image. Also my tests wont fail.

@jennifer-shehane jennifer-shehane added the v6.5.0 🐛 Issue present since 6.5.0 label Apr 29, 2021
@jennifer-shehane
Copy link
Member

@kkaarreell Yah, this likely has something to do with it. I'm not sure why this warning only displays for some people and not others. Do any of you have nodeVersion set in Cypress?

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: needs information Not enough info to reproduce the issue labels Apr 29, 2021
@jennifer-shehane jennifer-shehane added type: unexpected behavior User expected result, but got another and removed stage: work in progress labels Apr 29, 2021
@jennifer-shehane jennifer-shehane self-assigned this Apr 30, 2021
@cypress-bot cypress-bot bot added stage: work in progress and removed stage: needs review The PR code is done & tested, needs review labels May 4, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 4, 2021

The code for this is done in cypress-io/cypress#16277, 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 May 10, 2021

Released in 7.3.0.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators May 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: unexpected behavior User expected result, but got another v6.5.0 🐛 Issue present since 6.5.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants