Skip to content

Commit

Permalink
add support for fetch timeout control for node_helpers, fix timeouts …
Browse files Browse the repository at this point in the history
…on armv6l (MagicMirrorOrg#3660)

user reporting slow/no connection/timeout errors on armv6l for calendar,
and newsfeed

we can increase the timeout by adding calls to the undici lib, but it
requires node 20.18.1 or above.

this adds the support for timeout
(also environment variable to override if needed,, mmFetchTimeout
(default 30 seconds)

and updates the base node version
  • Loading branch information
sdetweil authored Dec 25, 2024
1 parent 2fb5143 commit 6a09bc4
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 162 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/automated-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
timeout-minutes: 30
strategy:
matrix:
node-version: [20.9.0, 20.x, 22.x, 23.x]
node-version: [20.18.1, 20.x, 22.x, 23.x]
steps:
- name: "Checkout code"
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/electron-rebuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.9.0, 20.x, 22.x, 23.x]
node-version: [20.18.1, 20.x, 22.x, 23.x]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ _This release is scheduled to be released on 2025-01-01._
- [linter] Add linting for markdown files (#3646)
- [calendar] Add ability to display end date for full date events, where end is not same day (showEnd=true) (#3650)
- [core] Add text to the config.js.sample file about the locale variable (#3654, #3655)
- [core] Add fetch timeout for all node_helpers (thru undici, forces node 20.18.1 minimum) to help on slower systems.

### Changed

Expand Down
7 changes: 7 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ const Utils = require(`${__dirname}/utils`);
const defaultModules = require(`${__dirname}/../modules/default/defaultmodules`);
const { getEnvVarsAsObj } = require(`${__dirname}/server_functions`);

// used to control fetch timeout for node_helpers
const { setGlobalDispatcher, Agent } = require("undici");
// common timeout value, provide environment override in case
const fetch_timeout = process.env.mmFetchTimeout !== undefined ? process.env.mmFetchTimeout : 30000;

// Get version number.
global.version = require(`${__dirname}/../package.json`).version;
global.mmTestMode = process.env.mmTestMode === "true" ? true : false;
Expand Down Expand Up @@ -295,6 +300,8 @@ function App () {
}
}

setGlobalDispatcher(new Agent({ connect: { timeout: fetch_timeout } }));

await loadModules(modules);

httpServer = new Server(config);
Expand Down
Loading

0 comments on commit 6a09bc4

Please sign in to comment.