fix: disable Olm on web — /keys/upload 400 crashed client init

The web session generates new Olm keys for an existing device ID.
Synapse rejects the upload (400 — keys mismatch) which crashes the
entire client init. Result: no sync, no room history, no calls.

Proper E2EE requires persistent Olm account storage (IndexedDB) so
the same device ID always sends the same keys. Deferred to Phase 3.

Without Olm loaded, the Matrix SDK gracefully skips encryption init.
Unencrypted rooms work fully. E2EE rooms show 'Encrypted message'.

Also unregisters stale service workers that served cached old JS
(caused calls to use the old GET URL instead of POST /sfu/get).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-03 15:56:46 +10:00
parent 41accdba81
commit fd7b64a89b

View File

@@ -39,22 +39,22 @@
Strategy: load olm.js synchronously, await Olm.init(), THEN inject Strategy: load olm.js synchronously, await Olm.init(), THEN inject
flutter_bootstrap.js dynamically so Flutter never starts before Olm. flutter_bootstrap.js dynamically so Flutter never starts before Olm.
--> -->
<script src="olm.js"></script>
<script> <script>
Olm.init({ locateFile: function() { return 'olm.wasm'; } }) // Unregister any stale service worker from previous builds — cached old JS
.then(function() { // causes calls and features to use outdated code silently.
var s = document.createElement('script'); if ('serviceWorker' in navigator) {
s.src = 'flutter_bootstrap.js'; navigator.serviceWorker.getRegistrations().then(function(registrations) {
document.body.appendChild(s); for (var r of registrations) { r.unregister(); }
})
.catch(function(e) {
// Olm failed — start Flutter anyway so user sees an error screen
// rather than a blank page.
console.warn('[M8Chat] Olm init failed:', e);
var s = document.createElement('script');
s.src = 'flutter_bootstrap.js';
document.body.appendChild(s);
}); });
}
</script> </script>
<!--
Olm (E2EE) disabled for Phase 1 web builds. The Matrix SDK gracefully
skips encryption when Olm is not loaded — unencrypted rooms work fine.
E2EE requires persistent Olm account storage (IndexedDB) to avoid
device key conflicts on /keys/upload (400). Deferred to Phase 3.
The olm.js and olm.wasm files remain deployed for future use.
-->
<script src="flutter_bootstrap.js" async></script>
</body> </body>
</html> </html>