Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ _This release is scheduled to be released on 2024-10-01._

- Fixed `checks` badge in README.md
- [weather] Fixed issue with the UK Met Office provider following a change in their API paths and header info.
- [core] add check for node_helper loading for multiple instances of same module (#3502)

## [2.28.0] - 2024-07-01

Expand Down
24 changes: 17 additions & 7 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Log = require("logger");
const Server = require(`${__dirname}/server`);
const Utils = require(`${__dirname}/utils`);
const defaultModules = require(`${__dirname}/../modules/default/defaultmodules`);
const helperhash = {};

// Get version number.
global.version = require(`${__dirname}/../package.json`).version;
Expand Down Expand Up @@ -175,14 +176,23 @@ function App () {

const helperPath = `${moduleFolder}/node_helper.js`;

let loadHelper = true;
try {
fs.accessSync(helperPath, fs.R_OK);
} catch (e) {
loadHelper = false;
Log.log(`No helper found for module: ${moduleName}.`);
}
// find out if helper was loaded before for this module
// only load it once
let loadHelper = helperhash[moduleName] ? false : true;

// if this is the 1st time for this module, check for helper file
// otherwise, its already loaded, if found
if (loadHelper) {
try {
fs.accessSync(helperPath, fs.R_OK);
// indicte we found one to load for this module
helperhash[moduleName] = true;
} catch (e) {
loadHelper = false;
Log.log(`No helper found for module: ${moduleName}.`);
}
}
// if the helper was found, AND needed 1st time
if (loadHelper) {
const Module = require(helperPath);
let m = new Module();
Expand Down