Skip to content

Commit

Permalink
chore: try/catch require.resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarchaud committed Feb 8, 2020
1 parent 2934a79 commit 29e07e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions packages/opentelemetry-node/src/instrumentation/PluginLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ export class PluginLoader {
const alreadyRequiredModules = Object.keys(require.cache);
const requiredModulesToHook = modulesToHook.filter(
name =>
alreadyRequiredModules.find(
cached => require.resolve(name) === cached
) !== undefined
alreadyRequiredModules.find(cached => {
try {
return require.resolve(name) === cached;
} catch (err) {
return false;
}
}) !== undefined
);
if (requiredModulesToHook.length > 0) {
this.logger.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ describe('PluginLoader', () => {
},
};
require('already-require-module');
const pluginLoader = new PluginLoader(registry, verifyWarnLogger);
const pluginLoader = new PluginLoader(provider, verifyWarnLogger);
pluginLoader.load(alreadyRequiredPlugins);
pluginLoader.unload();
});
Expand Down

0 comments on commit 29e07e6

Please sign in to comment.