Skip to content

Commit 54af1ea

Browse files
committed
chore: no try catch
1 parent d46c62a commit 54af1ea

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

packages/core/src/util/applicationUnderMonitoring.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,13 @@ 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+
// In case if require.main or process.argv[1] might be missing or invalid,
191+
// so mainModule.filename can be undefined.
192+
if (!mainModule?.filename) {
193+
logger.warn('Application entrypoint could not be identified. Package.json resolution will be skipped.');
202194
return process.nextTick(cb);
203195
}
196+
startDirectory = path.dirname(mainModule.filename);
204197
}
205198

206199
searchForPackageJsonInDirectoryTreeUpwards(startDirectory, (err, main) => {

0 commit comments

Comments
 (0)