Skip to content

Commit c6f8359

Browse files
committed
Give each FletApp a unique backend-channel address
Embedded FletApps (Preview's inner Pyodide app) all default to an empty `url`, so their backend channel address collapses to "" and multiple instances collide in the JS-side `_apps` registry used by jsConnect/jsSend/jsDisconnect. When one FletApp disposed, jsDisconnect would terminate whichever worker was last registered under "" — which is a *different* FletApp's worker. Synthesize a stable per-instance address from the control id when `url` is empty. The factory still picks the Pyodide/JavaScript channel under forcePyodide, so there's no routing impact.
1 parent 30b54a6 commit c6f8359

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

packages/flet/lib/src/controls/flet_app_control.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ class _FletAppControlState extends State<FletAppControl> {
2525
debugPrint("FletApp build: ${widget.control.id}");
2626

2727
var url = widget.control.getString("url", "")!;
28+
// Multiple embedded FletApps on the same page (e.g. a Preview inside
29+
// another Flet app) each leave `url` empty, which collides in the
30+
// JS-side worker registry keyed on `address`. Synthesize a unique
31+
// address from the control id so each backend channel is its own.
32+
if (url.isEmpty) {
33+
url = "embedded:${widget.control.id}";
34+
}
2835
var reconnectIntervalMs = widget.control.getInt("reconnect_interval_ms");
2936
var reconnectTimeoutMs = widget.control.getInt("reconnect_timeout_ms");
3037
var showAppStartupScreen =

0 commit comments

Comments
 (0)