Skip to content

Commit

Permalink
Fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
serkan-ozal committed Nov 6, 2024
1 parent 1025833 commit c0be5ce
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,23 @@ export class AwsLambdaInstrumentation extends InstrumentationBase<AwsLambdaInstr
// Lambda loads user function using an absolute path.
let filename = path.resolve(taskRoot, moduleRoot, module);
if (!filename.endsWith('.js')) {
// Its impossible to know in advance if the user has a js, cjs or mjs file.
// Check that the .js file exists otherwise fallback to the next known possibilities (.cjs, .mjs).
// It's impossible to know in advance if the user has a js, mjs or cjs file.
// Check that the .js file exists otherwise fallback to the next known possibilities (.mjs, .cjs).
try {
fs.statSync(`${filename}.js`);
filename += '.js';
} catch (e) {
try {
fs.statSync(`${filename}.cjs`);
// fallback to .cjs (CommonJS)
filename += '.cjs';
fs.statSync(`${filename}.mjs`);
// fallback to .mjs (ESM)
filename += '.mjs';

Check warning on line 109 in plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts

View check run for this annotation

Codecov / codecov/patch

plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts#L109

Added line #L109 was not covered by tests
} catch (e2) {
try {
fs.statSync(`${filename}.mjs`);
// fallback to .mjs (ESM)
filename += '.mjs';
fs.statSync(`${filename}.cjs`);
// fallback to .cjs (CommonJS)
filename += '.cjs';
} catch (e3) {
diag.error(
this._diag.warn(

Check warning on line 116 in plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts

View check run for this annotation

Codecov / codecov/patch

plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts#L116

Added line #L116 was not covered by tests
'No handler file was able to resolved with one of the known extensions for the file',
filename
);
Expand Down

0 comments on commit c0be5ce

Please sign in to comment.