testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

Infinite cycle on video recorder when heartbeat fails

Open zamprano opened this issue 1 year ago • 1 comments

What is your Scenario?

When the heartbeat fails, the framework enters an infinite cycle, on the video recorder, filling the logs with the same error message until it blows up. Any test with video recording can be impacted. The error message (repeated until log is 2+ Gb) is:

TypeError: Cannot destructure property 'browserClient' of 'this.openedBrowsers[browserId]' as it is undefined.
    at BrowserProviderPluginHost.getVideoFrameData (node_modules\testcafe\src\browser\provider\built-in\dedicated\chrome\index.js:172:17)
    at BrowserProvider.getVideoFrameData (node_modules\testcafe\src\browser\provider\index.ts:425:28)
    at VideoRecorder._capture (node_modules\testcafe\src\video-recorder\process.js:118:62)

We've traced the error to: node_modules\testcafe\lib\video-recorder\process.js, where it keeps calling getVideoFrameData() infinitely:

async _capture() {
	while (this.active) {
		try {
			const frame = await this.connection.provider.getVideoFrameData(this.connection.id);
			if (frame) {
				await this.emit('frame');
				await this._addFrame(frame);
			}
			else {
				await (0, delay_1.default)(DELAY_AFTER_EMPTY_FRAME);
			}
		}
		catch (error) {
			this.debugLogger(error);
		}
	}
}

As a patch, we're modifying node_modules\testcafe\lib\browser\provider\index.js, adding a validation that the browserId is still valid:

async getVideoFrameData(browserId) {
	if (!this.localBrowsersInfo[browserId]) return;
	return this.plugin.getVideoFrameData(browserId);
}

Even though the workaround works, it could be possible to find a better way to avid the issue.

What is the Current behavior?

  • No video.
  • No screenshots
  • Empty result reports.
  • Logs weighing 2+ Gb.

What is the Expected behavior?

The test restarts for a new attempt.

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

https://devexpress.github.io/testcafe/example

What is your TestCafe test code?

bug-reporting.ts:

import { Selector } from 'testcafe';

fixture('TestCafe example page')
    .page('https://devexpress.github.io/testcafe/example');

test('Bug reporting', async t => {
	await t
        .typeText('#developer-name2', 'John Smith')
        .click('#submit-button')
        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');
});

Your complete configuration file

No response

Your complete test report

N/A

Screenshots

N/A

Steps to Reproduce

Suggest updating HEARTBEAT_TIMEOUT on lib\utils\browser-connection-timeouts.js to 10s (default, 2min).

  1. Start any test.
  2. Once the test starts, open the browser's console and go to the Network tab.
  3. Change the throttling to Offline.
  4. Wait for the heartbeat to timeout and check the console.

TestCafe version

3.6.1

Node.js version

18.16.0

Command-line arguments

testcafe chrome bug-reporting.ts --video results/video --selector-timeout 150000

Browser name(s) and version(s)

Chrome 126

Platform(s) and version(s)

Windows 10

Other

Similar to https://github.com/DevExpress/testcafe/issues/6288

zamprano avatar Jun 13 '24 14:06 zamprano

We appreciate you taking the time to share information about this issue. We reproduced the bug and added this ticket to our internal task queue. We'll update this thread once we have news.

github-actions[bot] avatar Jun 17 '24 13:06 github-actions[bot]

This issue has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this issue in the future. If it still affects you or you have any additional information regarding it, please leave a comment and we will keep it open.

github-actions[bot] avatar Dec 15 '24 02:12 github-actions[bot]

We're closing this issue after a prolonged period of inactivity. If it still affects you, please add a comment to this issue with up-to-date information. Thank you.

github-actions[bot] avatar Dec 26 '24 01:12 github-actions[bot]