You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running an instance of Library with items in the customizations directory, these customizations may import their own modules using require. If an error occurs in any of the requires at the top of a customization file, the error thrown will have the code MODULE_NOT_FOUND, making our check for that error code in our requireWithFallback logic incorrectly assume the custom file does not exist:
// if the file exists but we failed to pull it in, log that error at a warning level
if(err.code!=='MODULE_NOT_FOUND'){
log.warn(`Failed pulling in custom file "${attemptPath}" @ ${customPath}. Error was:`,err)
}else{
log.debug(`No custom file "${attemptPath}" found in ${customPath}. Did you mean to include one?`)
}
This can make it confusing to debug issues with instances using customizations.
Expected Behavior
The full error prints telling me that my require failed.
Actual Behavior
The app incorrectly logs that no custom file exists at that path.
To Reproduce
Add a supported file to the custom directory, userAuth.js works well as it is required early in the main app.
At the top of that file, add the line require('FAKE_MODULE').
Run the app via LOG_LEVEL=debug npm run watch or LOG_LEVEL=debug npm run start.
Note the app logs No custom file "userAuth" found in /usr/src/app/custom/userAuth. Did you mean to include one?. This log line is incorrect.
Possible Solution
I think we should be able to check the require stack to make sure that server/utils.js is at the top of the stack. If a file with /custom/ in the path is the first thing in the require stack, we should log the entire error.
The text was updated successfully, but these errors were encountered:
Context
When running an instance of Library with items in the customizations directory, these customizations may import their own modules using
require
. If an error occurs in any of therequire
s at the top of a customization file, the error thrown will have the codeMODULE_NOT_FOUND
, making our check for that error code in ourrequireWithFallback
logic incorrectly assume the custom file does not exist:library/server/utils.js
Lines 57 to 62 in d85eb87
This can make it confusing to debug issues with instances using customizations.
Expected Behavior
The full error prints telling me that my require failed.
Actual Behavior
The app incorrectly logs that no custom file exists at that path.
To Reproduce
userAuth.js
works well as it is required early in the main app.require('FAKE_MODULE')
.LOG_LEVEL=debug npm run watch
orLOG_LEVEL=debug npm run start
.No custom file "userAuth" found in /usr/src/app/custom/userAuth. Did you mean to include one?
. This log line is incorrect.Possible Solution
I think we should be able to check the require stack to make sure that
server/utils.js
is at the top of the stack. If a file with/custom/
in the path is the first thing in the require stack, we should log the entire error.The text was updated successfully, but these errors were encountered: