Skip to content

Commit 6be5b89

Browse files
committed
feat: expose the v8 flags with our node introspection mechanism
1 parent a2d0d88 commit 6be5b89

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

packages/core/src/index.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,36 @@
1+
import { writeFileSync } from "fs";
12
import path from "path";
3+
4+
const getV8Flags = (nodeVersionMajor: number) => {
5+
const flags = [
6+
"--hash-seed=1",
7+
"--random-seed=1",
8+
"--no-opt",
9+
"--predictable",
10+
"--predictable-gc-schedule",
11+
];
12+
if (nodeVersionMajor < 18) {
13+
flags.push("--no-randomize-hashes");
14+
}
15+
if (nodeVersionMajor < 20) {
16+
flags.push("--no-scavenge-task");
17+
}
18+
return flags;
19+
};
20+
21+
if (process.env.__CODSPEED_NODE_CORE_INTROSPECTION_PATH__ !== undefined) {
22+
const nodeVersionMajor = parseInt(process.version.slice(1).split(".")[0]);
23+
24+
const introspectionMetadata = {
25+
flags: getV8Flags(nodeVersionMajor),
26+
};
27+
writeFileSync(
28+
process.env.__CODSPEED_NODE_CORE_INTROSPECTION_PATH__,
29+
JSON.stringify(introspectionMetadata)
30+
);
31+
process.exit(0);
32+
}
33+
234
declare const __VERSION__: string;
335

436
/* eslint-disable @typescript-eslint/no-empty-function */

0 commit comments

Comments
 (0)