Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(preload): fail quietly on synchronous errors and document the no-polyfill rule

Hristo Terezov413e4321ddb0
diff --git a/react/features/preload/preload.web.ts b/react/features/preload/preload.web.ts
index 7e1b617095..392e2732c4 100644
--- a/react/features/preload/preload.web.ts
+++ b/react/features/preload/preload.web.ts
@@ -15,6 +15,10 @@ import { IJitsiMeetPreload } from './types';
* were requested from. The app reuses a result only when it would have requested exactly the same
* URL and handles every failure by requesting the resource itself, so nothing here may break the
* page: there is no logging and no dependency beyond the small URL helpers shared with the app.
+ *
+ * The bundle is built without core-js polyfills (see getPreloadRules in webpack.config.js), so this
+ * file and the modules it imports must only use built-ins available on the supported browser floor.
+ * TypeScript does not flag newer ones, and a missing one would silently disable the preload.
*/
const preload: IJitsiMeetPreload = {};
@@ -133,7 +137,13 @@ function preloadIcons(brandingUrl: string, data: { customIcons?: unknown; }): vo
}
// Besides starting the branding, this chain marks the published config promise as handled (see
-// preloadBranding for why that matters).
-preloadConfig()
- .then(preloadBranding)
- .catch(() => { /* Handled by the app, which loads the config itself. */ });
+// preloadBranding for why that matters). The chains cover the asynchronous parts; the try/catch
+// covers the synchronous ones, e.g. a built-in missing in an old browser, so that even then the
+// script fails quietly and the app simply requests everything itself.
+try {
+ preloadConfig()
+ .then(preloadBranding)
+ .catch(() => { /* Handled by the app, which loads the config itself. */ });
+} catch {
+ // Handled by the app, which loads everything itself.
+}
diff --git a/webpack.config.js b/webpack.config.js
index 3502e848a1..a59988231a 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -56,7 +56,10 @@ function getBundleAnalyzerPlugin(analyzeBundle, name) {
/**
* Builds the module rules for the preload script. It runs before the app bundle, in the same modern
* browsers the app requires, so the core-js polyfills babel injects for the app would only add
- * weight to a script whose whole point is to be small and fast.
+ * weight to a script whose whole point is to be small and fast (51 KiB with them, 7 KiB without).
+ * Syntax is still transpiled for the configured targets; only polyfill injection is disabled. The
+ * flip side: the preload and the modules it imports must only use built-ins available on the
+ * supported browser floor, and nothing enforces that automatically.
*
* @param {Array} rules - The shared module rules.
* @returns {Array} The rules with polyfill injection disabled.