Skip to content

Commit

Permalink
feat: expose the v8 flags with our node introspection mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
art049 committed Jun 27, 2023
1 parent a2d0d88 commit 6be5b89
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
import { writeFileSync } from "fs";
import path from "path";

const getV8Flags = (nodeVersionMajor: number) => {
const flags = [
"--hash-seed=1",
"--random-seed=1",
"--no-opt",
"--predictable",
"--predictable-gc-schedule",
];
if (nodeVersionMajor < 18) {
flags.push("--no-randomize-hashes");
}
if (nodeVersionMajor < 20) {
flags.push("--no-scavenge-task");
}
return flags;
};

if (process.env.__CODSPEED_NODE_CORE_INTROSPECTION_PATH__ !== undefined) {
const nodeVersionMajor = parseInt(process.version.slice(1).split(".")[0]);

const introspectionMetadata = {
flags: getV8Flags(nodeVersionMajor),
};
writeFileSync(
process.env.__CODSPEED_NODE_CORE_INTROSPECTION_PATH__,
JSON.stringify(introspectionMetadata)
);
process.exit(0);
}

declare const __VERSION__: string;

/* eslint-disable @typescript-eslint/no-empty-function */
Expand Down

0 comments on commit 6be5b89

Please sign in to comment.