Skip to content

TypeError: Cannot read properties of null (reading 'pendingTaskDonePromise') #8447

@connorpwilliams

Description

@connorpwilliams

What is your Scenario?

Using testcafe to run tests on a react app after building and serving with vite build/preview

What is the Current behavior?

I have seen a few bugs about this issue, cannot confirm if my case is the same, but I have a way to reproduce it.
When running tests that use appCommand config file value, if that application fails to start (in my case, because the port is already in use) I get the error in the subject line while running tests

What is the Expected behavior?

Repeatedly re-run tests

What is the public URL of the test page? (attach your complete example)

Private corporate link, cannot share.

What is your TestCafe test code?

Also unable to share as private corporate codebase, but it appears that any basic test causes the error

fixture('home').page('http://localhost:3000')
test('it loads', async t => await t.expect(Selector('body').exists).ok('Page loaded'))

^ Was able to cause error

Your complete configuration file

Removed non-applicable private info, minimal example provided

module.exports = {
    src: "./testcafe/*.test.js",
    browsers: [process.env.BROWSER || "chrome"],
    hostname: 'localhost',
    appCommand: 'npm run serve'
}

Your complete test report

No response

Screenshots

No response

Steps to Reproduce

Scenario:

  1. Use appCommand config file field to start an app on port 3000 (while that port is already in use)
  2. Somehow testcafe aborts and the appCommand is not terminated
  3. Run testcafe again - error occurs

I presume this would also cause error

  1. Start anything on port 3000
  2. Run testcafe command with appCommand field in config file running an app on port 3000 (in my specific case npm run serve which starts an app on localhost:3000)
  3. Received error TypeError: Cannot read properties of null (reading 'pendingTaskDonePromise')

Was able to see the error when turning on debug

  testcafe:tested-app:stderr error when starting preview server:
  testcafe:tested-app:stderr Error: Port 3000 is already in use
  ... omitted for privacy reasons ...
  testcafe:tested-app:stderr     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

TestCafe version

3.7.2

Node.js version

20.19.0

Command-line arguments

testcafe --esm -f "some fixture"

Browser name(s) and version(s)

Chrome

Platform(s) and version(s)

Windows

Other

I am not convinced the error is that the port is already in use, I am guessing it's more generic that "appCommand" failed to start the app (maybe?)
The error at least was reproducible with appCommand trying to start an app on a port that is already in use

Testcafe errors out with

TypeError: Cannot read properties of null (reading 'pendingTaskDonePromise')
    at C:\...path...\node_modules\testcafe\src\runner\index.js:181:75
    at Array.map (<anonymous>)
    at Runner._getTaskResult (C:\...path...\node_modules\testcafe\src\runner\index.js:181:41)

Wasn't able to re-open either related issues so referencing them here
Related: #8249
Related: #7805

Metadata

Metadata

Assignees

No one assigned

    Labels

    TYPE: bugThe described behavior is considered as wrong (bug).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions