Skip to content

Report Python startup errors in flet test; bump Flutter to 3.47.8 - #7023

Merged
FeodorFitsner merged 4 commits into
flet-1.1.0from
fix/flet-test-python-startup-error
Oct 29, 2026
Merged

FeodorFitsner merged 4 commits into
flet-1.1.0from
fix/flet-test-python-startup-error

Conversation

@ndonkoHenri

@ndonkoHenri ndonkoHenri commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Three independent changes for 1.1.0.

Report Python startup errors in flet test

When the app's Python program fails before it connects, for example on an import error, flet test waited out its two-minute startup timeout and failed with only:

The following TimeoutException was thrown running a test:
The app did not load its first page within 0:02:00.000000.
...
ERROR tests/test_main.py::test_increment - RuntimeError: Flutter process exit...

The traceback was only visible in the app window, so the reporter of #7022 added a sleep to their test to read it.

The build template reports a Python program that exits early on the boot status that draws the "Error running app" screen. waitForAppLoaded (added in #6995) only checked FletBackend.error, which is set by errors that arrive over the Flet protocol, so it never saw it. It now also checks the backend's bootStatus and fails right away with the error text:

The following _Exception was thrown running a test:
Exception: The app failed to start:
Traceback (most recent call last):
  File "...\main.py", line 4, in <module>
  File "...\site-packages\pydantic\__init__.py", line 5, in <module>
  ...
ModuleNotFoundError: No module named 'pydantic_core._pydantic_core'

Tested on Windows 11 with a Flet 1.1.0 project built from source whose main.py imports pydantic (which fails there because of flet-dev/serious-python#261): without -v, the failing test prints the traceback above instead of the timeout. app_startup_test.dart gets a case for an error reported only on the boot status while the backend is still loading; all 6 tests pass.

An error raised before FletApp is built, such as a failure while the app bundle is prepared, still times out: the driver can't reach the boot status at that point.

Bump Flutter to 3.47.8

.fvmrc 3.47.7 → 3.47.8 (Dart 3.13.5 → 3.13.7, and two flutter_tools crash fixes). pub get in client, packages/flet and packages/flet_integration_test leaves every lock file unchanged. The changelog link points at #3478, which Flutter's stable changelog doesn't have a section for yet.

Type use_ref() with a function initializer

The use_ref() half of #6960, which #7014 fixed for use_state() only. use_ref(initial_value: RefValueT | Callable[[], RefValueT] | None = None) put the TypeVar on both sides of a union, so ft.use_ref(create_state) was an error in mypy (falling back to Any) and the function-or-value union in ty. Three overloads, matching the use_state() ones:

@overload
def use_ref(initial_value: None = None) -> MutableRef[Any]: ...
@overload
def use_ref(initial_value: Callable[[], RefValueT]) -> MutableRef[RefValueT]: ...
@overload
def use_ref(initial_value: RefValueT | Callable[[], RefValueT]) -> MutableRef[RefValueT]: ...
  • A zero-argument function resolves to its return type: use_ref(create_state) → MutableRef[FormState].
  • use_ref() and use_ref(None) give MutableRef[Any], so an empty ref can be assigned later.
  • The last overload is the original signature, so custom hooks that pass a value-or-function through still type-check.

mypy, pyright and ty report 0 errors for these cases, use_state(create_state) still gives FormState, and the hook unit tests pass. The runtime is unchanged. The #6960 changelog entry now covers both hooks.

Summary by Sourcery

Improve startup failure reporting in flet test and update the bundled Flutter SDK to 3.47.8.

Bug Fixes:

  • Make flet test report Python startup tracebacks immediately instead of waiting for the app startup timeout.
  • Improve type inference for callable initializers passed to use_ref().
  • Update the changelog to reflect the startup error reporting fix.

Enhancements:

  • Update the bundled Flutter SDK to 3.47.8.

Build:

  • Bump the project Flutter version from 3.47.7 to 3.47.8.

Tests:

  • Add coverage for Python startup failures reported through the app boot status.

When the app's Python program failed before connecting, such as an import
error, the build template reported it only on the boot screen's status.
`waitForAppLoaded` checked only `FletBackend.error`, so `flet test` waited
out its two-minute timeout and failed with "The app did not load its first
page", without the traceback.

`waitForAppLoaded` now also checks the backend's boot status and fails
right away with the error text, so the test output includes the Python
traceback.
@sourcery-ai

sourcery-ai Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Sorry @ndonkoHenri, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 day and 22 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 24fd5ec
Status: ✅  Deploy successful!
Preview URL: https://735e9f3e.flet-website-v2.pages.dev
Branch Preview URL: https://fix-flet-test-python-startup.flet-website-v2.pages.dev

View logs

`use_ref(initial_value: RefValueT | Callable[[], RefValueT] | None = None)`
put the TypeVar on both sides of a union, as `use_state()` did before #7014:
mypy rejected a function initializer and fell back to `Any`, and ty inferred
the function-or-value union. Overloads now match a zero-argument function
first, keep the original union as the fallback so value-or-function
arguments passed through by custom hooks type as before, and give
`use_ref()` / `use_ref(None)` a `MutableRef[Any]` that can be assigned
later.
@FeodorFitsner
FeodorFitsner merged commit 11e1c85 into flet-1.1.0 Oct 29, 2026
79 of 132 checks passed
@FeodorFitsner
FeodorFitsner deleted the fix/flet-test-python-startup-error branch October 29, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants