Skip to content

Commit

Permalink
Only catch error if provider module itself does not exist
Browse files Browse the repository at this point in the history
Fixes DevExpress#4522 and DevExpress#4673.

First uses `require.resolve`, which will only throw an error if the provider module itself doesn't exist. If it does exist, we then use `require` to load the module, not catching errors. That way, any errors caused by a 3rd party dependency will show up.
  • Loading branch information
Dan Wenzel authored Jan 23, 2020
1 parent 251c9aa commit 2758d44
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/browser/provider/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,19 @@ export default {

_getProviderModule (providerName, moduleName) {
try {
const providerObject = require(moduleName);

this.addProvider(providerName, providerObject);
return this._getProviderFromCache(providerName);
// First, just check if the module exists
require.resolve(moduleName);
}
catch (e) {
// Module does not exist. Return null, and let the caller handle
return null;
}

// Load the module
const providerObject = require(moduleName);

this.addProvider(providerName, providerObject);
return this._getProviderFromCache(providerName);
},

_getProviderFromCache (providerName) {
Expand Down

0 comments on commit 2758d44

Please sign in to comment.