mirror of
https://github.com/morluto/rea.git
synced 2026-12-02 11:33:10 +00:00
test(process): share V8 heap exhaustion snapshots (#15769)
This commit is contained in:
1 parent
3e25603496
commit
2e8babb23a
4 files changed
+38
-56
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { v8HeapExhaustionFailure } from "../../../tests/fixtures/providerProcess.js";
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { expect, it } from "vitest";
|
||||
@@ -66,24 +67,9 @@ it.each([
|
||||
});
|
||||
const stderr =
|
||||
"FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory\r\n";
|
||||
const cause = new OwnedCommandFailure("process", "Decoder failed", {
|
||||
stdout: { text: "", bytes: 0, observedBytes: 0 },
|
||||
stderr: {
|
||||
text: stderr,
|
||||
bytes: Buffer.byteLength(stderr),
|
||||
observedBytes: Buffer.byteLength(stderr),
|
||||
},
|
||||
const cause = v8HeapExhaustionFailure("Decoder failed", stderr, {
|
||||
exitCode,
|
||||
signal,
|
||||
runtimeExhaustion: {
|
||||
runtime: "v8",
|
||||
area: "heap",
|
||||
stream: "stderr",
|
||||
line: stderr.trim(),
|
||||
lineComplete: true,
|
||||
truncated: false,
|
||||
invalidUtf8: false,
|
||||
},
|
||||
});
|
||||
const projected = analysisErrorProjectionSchema.parse(
|
||||
projectAnalysisError(historicalCaptureFailure(input, cause, "decoder")),
|
||||
|
||||
@@ -11,7 +11,7 @@ import { historicalCaptureFailure } from "../browser/history/CaptureFailures.js"
|
||||
import { ConfigurationError } from "../domain/configurationErrors.js";
|
||||
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
||||
import { inspectWebNetworkCaptureInputSchema } from "../domain/webNetworkCapture.js";
|
||||
import { OwnedCommandFailure } from "../process/OwnedCommand.js";
|
||||
import { v8HeapExhaustionFailure } from "../../tests/fixtures/providerProcess.js";
|
||||
import { createWebNetworkCaptureService } from "../composition/webNetworkCaptures.js";
|
||||
import { createCli } from "../cli.js";
|
||||
import { historicalHar } from "../../tests/fixtures/historicalHar.js";
|
||||
@@ -34,25 +34,7 @@ const configured = (oldGenerationMiB: number) =>
|
||||
const heapExhaustion = () => {
|
||||
const stderr =
|
||||
"FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory\n";
|
||||
return new OwnedCommandFailure("process", "Decoder failed", {
|
||||
stdout: { text: "", bytes: 0, observedBytes: 0 },
|
||||
stderr: {
|
||||
text: stderr,
|
||||
bytes: Buffer.byteLength(stderr),
|
||||
observedBytes: Buffer.byteLength(stderr),
|
||||
},
|
||||
exitCode: null,
|
||||
signal: "SIGABRT",
|
||||
runtimeExhaustion: {
|
||||
runtime: "v8",
|
||||
area: "heap",
|
||||
stream: "stderr",
|
||||
line: stderr.trim(),
|
||||
lineComplete: true,
|
||||
truncated: false,
|
||||
invalidUtf8: false,
|
||||
},
|
||||
});
|
||||
return v8HeapExhaustionFailure("Decoder failed", stderr);
|
||||
};
|
||||
|
||||
it("keeps the 192 MiB decoder heap when the setting is unset", async () => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { v8HeapExhaustionFailure } from "../../fixtures/providerProcess.js";
|
||||
import { SqliteDatabaseProvider } from "../../../src/sqlite/SqliteDatabaseProvider.js";
|
||||
import { createSqliteDatabaseFixture } from "../../fixtures/sqlite/database.js";
|
||||
import { spawnFailure } from "../../support/process/spawnFailure.js";
|
||||
@@ -145,25 +146,7 @@ it.each(["/selected.db", "./Database files/another.db"])(
|
||||
(path) => {
|
||||
const stderr =
|
||||
"FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory";
|
||||
const cause = new OwnedCommandFailure("process", "Worker exited.", {
|
||||
stdout: { text: "", bytes: 0, observedBytes: 0 },
|
||||
stderr: {
|
||||
text: stderr,
|
||||
bytes: Buffer.byteLength(stderr),
|
||||
observedBytes: Buffer.byteLength(stderr),
|
||||
},
|
||||
exitCode: null,
|
||||
signal: "SIGABRT",
|
||||
runtimeExhaustion: {
|
||||
runtime: "v8",
|
||||
area: "heap",
|
||||
stream: "stderr",
|
||||
line: stderr.trim(),
|
||||
lineComplete: true,
|
||||
truncated: false,
|
||||
invalidUtf8: false,
|
||||
},
|
||||
});
|
||||
const cause = v8HeapExhaustionFailure("Worker exited.", stderr);
|
||||
const failure = classifyProviderFailure(
|
||||
cause,
|
||||
sqliteDatabaseDialect(path, "worker"),
|
||||
|
||||
Vendored
+32
-1
@@ -1,6 +1,10 @@
|
||||
import { spawn, type ChildProcess } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import type { ProviderProcessHandle } from "../../src/process/ProviderProcess.js";
|
||||
import { OwnedCommandFailure } from "../../src/process/OwnedCommand.js";
|
||||
import type {
|
||||
ProviderProcessHandle,
|
||||
ProviderProcessSnapshot,
|
||||
} from "../../src/process/ProviderProcess.js";
|
||||
import { testWaitDeadline } from "../support/testWait.js";
|
||||
|
||||
const fixturePath = fileURLToPath(
|
||||
@@ -114,3 +118,30 @@ export const stopProviderProcessFixture = async (
|
||||
child.kill("SIGKILL");
|
||||
await exited;
|
||||
};
|
||||
|
||||
/** Build an owned-process snapshot with a complete V8 heap diagnostic. */
|
||||
export const v8HeapExhaustionFailure = (
|
||||
message: string,
|
||||
stderr: string,
|
||||
termination: Pick<ProviderProcessSnapshot, "exitCode" | "signal"> = {
|
||||
exitCode: null,
|
||||
signal: "SIGABRT",
|
||||
},
|
||||
): OwnedCommandFailure => {
|
||||
const bytes = Buffer.byteLength(stderr);
|
||||
return new OwnedCommandFailure("process", message, {
|
||||
stdout: { text: "", bytes: 0, observedBytes: 0 },
|
||||
stderr: { text: stderr, bytes, observedBytes: bytes },
|
||||
exitCode: termination.exitCode,
|
||||
signal: termination.signal,
|
||||
runtimeExhaustion: {
|
||||
runtime: "v8",
|
||||
area: "heap",
|
||||
stream: "stderr",
|
||||
line: stderr.trim(),
|
||||
lineComplete: true,
|
||||
truncated: false,
|
||||
invalidUtf8: false,
|
||||
},
|
||||
});
|
||||
};
|
||||
Reference in new issue
Block a user