File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed
plugins/node/opentelemetry-instrumentation-aws-lambda/src Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -116,15 +116,11 @@ export class AwsLambdaInstrumentation extends InstrumentationBase {
116116 // Lambda loads user function using an absolute path.
117117 let filename = path . resolve ( taskRoot , moduleRoot , module ) ;
118118 if ( ! filename . endsWith ( '.js' ) ) {
119- // its impossible to know in advance if the user has a cjs or js file.
120- // check that the .js file exists otherwise fallback to next known possibility
121- try {
122- fs . statSync ( `${ filename } .js` ) ;
123- filename += '.js' ;
124- } catch ( e ) {
125- // fallback to .cjs
126- filename += '.cjs' ;
127- }
119+ // its impossible to know in advance if the user has a cjs, mjs or js file.
120+ // check that the .js file exists otherwise fallback to next known possibilities
121+ if ( fs . existsSync ( `${ filename } .js` ) ) filename += '.js' ;
122+ else if ( fs . existsSync ( `${ filename } .mjs` ) ) filename += '.mjs' ;
123+ else filename += '.cjs' ;
128124 }
129125
130126 diag . debug ( 'Instrumenting lambda handler' , {
You can’t perform that action at this time.
0 commit comments