Skip to content

Commit 08e3837

Browse files
fix: add null-safety for configData.moduleData access
Prevent crash when API is called before frontend sends CURRENT_STATUS by using optional chaining (?.) on moduleData.find() call. Fixes race condition during startup that caused: TypeError: Cannot read properties of undefined (reading 'find')
1 parent 9f0962b commit 08e3837

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

node_helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ module.exports = NodeHelper.create({
382382
const current = config.modules[i];
383383
const moduleDefaultsFromRequire = Module.configDefaults[current.module];
384384
// We need moduleDataFromBrowser for bundled modules like MMM-RAIN-MAP. See #331.
385-
const moduleDataFromBrowser = this.configData.moduleData.find((item) => item.name === current.module);
385+
const moduleDataFromBrowser = this.configData.moduleData?.find((item) => item.name === current.module);
386386

387387
const moduleConfig = moduleDefaultsFromRequire || moduleDataFromBrowser?.config || {};
388388

0 commit comments

Comments
 (0)