-
Notifications
You must be signed in to change notification settings - Fork 675
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
ClientFunction not working for returning large object/array #1110
Comments
Hi, thanks for the report. We need some time to investigate it. |
Hi @thecodejack, I've tried to reproduce the issue on my side using the following code: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
window.rows = [];
for (var i = 0; i < 100000; i++)
window.rows.push({ name: 'row' + i, payload: 'Hey42' });
</script>
</body>
</html> test.js import { ClientFunction } from 'testcafe';
fixture `gh1110`
.page `http://localhost:8080`;
const getRows = ClientFunction(() => window.rows);
test('Count rows', async t => {
const rows = await getRows();
await t.expect(rows.length).eql(100000);
}); While test run took some noticeable time, it's completed successfully. Is there something what I'm missing? |
This makes it failing in my PC:
|
I was able to reproduce the issue. The cause of the problem is that browser runs out of memory when we try to serialize enormously large object. I guess the best option here will be a limit for the returned object size, let's just throw an error with some descriptive message. |
Closing this issue in favor of #2618. |
@AndreyBelym is there another way for returning very large objects? #2618 is not sufficient since I need to transfer objects of that size. I do code-coverage analysis using istanbul-instrumenter. The coverage is logged in window.coverage and I need to access this after a successful test-run. |
Since I can stringify my object, I wrote a helper function that checks the size first, and then I call multiple times into the browser and copy the data I need: const maximumObjectSize = 1024 * 1024 * 4.0; // 4 mb - to be sure
export const codeCoverageSize = ClientFunction(() => {
const json = JSON.stringify((window as any).__coverage__);
(window as any).__coverage_json__ = json;
return json.length;
});
export const codeCoverage = ClientFunction((start: number, end: number) => {
return (window as any).__coverage_json__.substring(start, end);
});
export const collectCodeCoverage = async (fileName = randomNotebookTag()) => {
const size = await codeCoverageSize();
const splits = Math.ceil(size / maximumObjectSize);
let coverageJson = '';
for (let i = 0; i < splits; i++) {
const start = i * maximumObjectSize;
coverageJson += await codeCoverage(start, start + maximumObjectSize);
}
console.log(coverageJson);
}; |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests. For TestCafe API, usage and configuration inquiries, we recommend asking them on StackOverflow. |
Are you requesting a feature or reporting a bug?
Bug
What is the current behavior?
TestCafe keeps waiting at ClientFunction when returning object/array which is very large for following code.
gridData is expected to have around 99k objects in an array. But while running tests, tests are not going forward. It is not even throwing any error. it just waits.
What is the expected behavior?
Should either throw error of memory limit or return the data.
How would you reproduce the current behavior (if this is a bug)?
Take any very large dataset and return it from application url through ClientFunction.
Provide the test code and the tested page URL (if applicable)
Tested page URL:
Test code
Specify your
The text was updated successfully, but these errors were encountered: