test: replace jest workers past 200 MB so they exit in time (closes #766)
On a starved CPU, jest force-stopped worker processes that could not exit within the 500 ms it allows, and script/lib/jest.js failed the run although every test passed. No test leaks a handle; exit time grows with what a worker holds, 380 to 970 MB at the end of the run. workerIdleMemoryLimit in package.json replaces a worker whose heap is over 200 MB after a test file with a fresh one. tests/jestRunner.test.js runs script/lib/jest.js on a fixture that leaves an interval running and expects the force-stop to fail the run. Model: opus-5-5
This commit is contained in:
1 parent
b77b04b714
commit
08adee9b01
4 files changed
+45
-3
No files matched your search
+7
@@ -0,0 +1,7 @@
|
||||
// A test file that starts an interval and never clears it.
|
||||
// tests/jestRunner.test.js runs script/lib/jest.js on this file alone. The
|
||||
// name does not end in .test.js, so the normal run never picks it up.
|
||||
|
||||
test("starts an interval and never clears it", () => {
|
||||
setInterval(() => {}, 1000);
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
// script/lib/jest.js, which package.json's test scripts run, fails a run in
|
||||
// which jest force-stopped a worker process because a test left an open
|
||||
// handle.
|
||||
|
||||
const { spawnSync } = require("child_process");
|
||||
const path = require("path");
|
||||
|
||||
const root = path.join(__dirname, "..");
|
||||
|
||||
test("a test that leaves an interval running fails the run", () => {
|
||||
// The memory limit in package.json makes jest run even this one file in a
|
||||
// worker process. The interval keeps that worker from exiting, so jest
|
||||
// force-stops it after the run.
|
||||
const result = spawnSync(
|
||||
process.execPath,
|
||||
[
|
||||
"script/lib/jest.js",
|
||||
"--maxWorkers=1",
|
||||
"--testMatch",
|
||||
"<rootDir>/tests/fixtures/leavesIntervalRunning.js",
|
||||
],
|
||||
{ cwd: root, encoding: "utf8", timeout: 20000 },
|
||||
);
|
||||
|
||||
expect(result.signal).toBeNull();
|
||||
expect(result.status).toBe(1);
|
||||
expect(result.stderr).toContain("1 passed");
|
||||
expect(result.stderr).toContain("jest force-stopped a worker process");
|
||||
});
|
||||
Reference in new issue
Block a user