MCPcopy Index your code
hub / github.com/MagicMirrorOrg/MagicMirror / scheduleNextFetch

Method scheduleNextFetch

js/http_fetcher.js:111–126  ·  view source on GitHub ↗

* Schedules the next fetch. * If no delay is provided, uses reloadInterval. * If delay is provided but very short (< 1 second), clamps to reloadInterval * to prevent hammering servers. * @param {number} [delay] - Delay in milliseconds

(delay)

Source from the content-addressed store, hash-verified

109 * @param {number} [delay] - Delay in milliseconds
110 */
111 scheduleNextFetch (delay) {
112 let nextDelay = delay ?? this.reloadInterval;
113
114 // Only clamp if delay is unreasonably short (< 1 second)
115 // This allows respecting Retry-After headers while preventing abuse
116 if (nextDelay < 1000) {
117 nextDelay = this.reloadInterval;
118 }
119
120 // Don't schedule in test mode
121 if (process.env.mmTestMode === "true") {
122 return;
123 }
124
125 this.reloadTimer = setTimeout(() => this.fetch(), nextDelay);
126 }
127
128 /**
129 * Starts periodic fetching

Callers 2

fetchMethod · 0.95
performFetchFunction · 0.80

Calls 1

fetchMethod · 0.95

Tested by

no test coverage detected