Skip to content

Commit

Permalink
fix: if execution id support requested for node 12, fail open and dro…
Browse files Browse the repository at this point in the history
…p execution id support instead of crashing out (#618)
  • Loading branch information
jrmfg authored Jul 8, 2024
1 parent 96ae8aa commit 47003fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,13 @@ const ExecutionIdOption = new ConfigurableOption(
(typeof x === 'boolean' && x) ||
(typeof x === 'string' && x.toLowerCase() === 'true');
if (isTrue && !isVersionSatisfied) {
throw new OptionsError(
`Execution id is only supported with Node.js versions ${requiredNodeJsVersionForLogExecutionID} and above. Your current version is ${nodeVersion}. Please upgrade.`
console.warn(
`Execution id is only supported with Node.js versions
${requiredNodeJsVersionForLogExecutionID} and above. Your
current version is ${nodeVersion}. Please upgrade.`
);
console.warn('Proceeding with execution id support disabled...');
return false;
}
return isTrue;
}
Expand Down
6 changes: 2 additions & 4 deletions test/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,12 @@ describe('parseOptions', () => {

executionIdTestData.forEach(testCase => {
it(testCase.name, () => {
const options = parseOptions(testCase.cliOpts, testCase.envVars);
if (
semver.lt(process.versions.node, requiredNodeJsVersionForLogExecutionID)
) {
assert.throws(() => {
parseOptions(testCase.cliOpts, testCase.envVars);
});
assert.strictEqual(options.enableExecutionId, false);
} else {
const options = parseOptions(testCase.cliOpts, testCase.envVars);
assert.strictEqual(options.enableExecutionId, true);
}
});
Expand Down

0 comments on commit 47003fd

Please sign in to comment.