testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

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

Open connorpwilliams opened this issue 3 months ago • 3 comments

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: https://github.com/DevExpress/testcafe/issues/8249 Related: https://github.com/DevExpress/testcafe/issues/7805

connorpwilliams avatar Oct 03 '25 15:10 connorpwilliams

Thank you for submitting a bug report. We would love to help you investigate the issue. Please share a simple code example that reliably reproduces the bug. For more information, read the following article: How To Create a Minimal Working Example When You Submit an Issue. We look forward to your response.

github-actions[bot] avatar Oct 07 '25 07:10 github-actions[bot]

I am not sure what more to provide. I have an example test file, and configuration file above. To provide a working example I'd need to have an application served on a port, and started with the testcafe appCommand configuration. Do you want me to include a default react app from some templating engine?

connorpwilliams avatar Oct 10 '25 14:10 connorpwilliams

Do you want me to include a default react app from some templating engine?

Yes, please. If possible, share a web application project where we can reproduce the issue, along with short instructions on how to run it locally. This will ensure that we investigate the exact problematic behavior and help us process your inquiry more efficiently.

aleks-pro avatar Oct 13 '25 10:10 aleks-pro