@@ -187,20 +187,15 @@ function getMainPackageJsonPathStartingAtDirectory(startDirectory, cb) {
187187 }
188188 }
189189
190- try {
191- // The collector may be preloaded via --require in ESM apps or frameworks (e.g., react-scripts),
192- // which is not supported and can happen in auto-tracing setups.
193- // In such cases, require.main or process.argv[1] might be missing or invalid,
194- // so mainModule.filename can be undefined.
195- if ( ! mainModule ?. filename ) {
196- logger . warn ( 'Application entrypoint could not be identified. Package.json resolution will be skipped.' ) ;
197- return process . nextTick ( cb ) ;
198- }
199- startDirectory = path . dirname ( mainModule . filename ) ;
200- } catch ( e ) {
201- logger . warn ( `Unable to resolve application entrypoint ${ e . message } . Package.json resolution will be skipped.` ) ;
190+ // The collector may be preloaded via --require in ESM apps or frameworks (react, angular),
191+ // which is not supported and can happen from auto-tracing as well.
192+ // In such cases, require.main or process.argv[1] might be missing or invalid,
193+ // so mainModule.filename can be undefined.
194+ if ( ! mainModule ?. filename ) {
195+ logger . warn ( 'Application entrypoint could not be identified. Package.json resolution will be skipped.' ) ;
202196 return process . nextTick ( cb ) ;
203197 }
198+ startDirectory = path . dirname ( mainModule . filename ) ;
204199 }
205200
206201 searchForPackageJsonInDirectoryTreeUpwards ( startDirectory , ( err , main ) => {
0 commit comments