Skip to content

Commit ce1d1c8

Browse files
v1: Fix use_effect hook with async handler (#5762)
* Replace Exception with specific error types Replaces generic Exception raises with more specific error types such as RuntimeError, ValueError, NotImplementedError, ImportError, and custom exceptions across multiple modules. This improves error handling clarity and aligns with Python best practices for exception usage. * Set res to None before running hook setup Added initialization of the 'res' variable to None before executing hook setup in the Session class. This change clarifies the state of 'res' prior to its use and may help prevent potential issues with uninitialized variables. * Improve upload size exceeded error message The HTTP 413 error now includes the maximum allowed upload size in bytes for better clarity when the limit is exceeded.
1 parent fc43cf9 commit ce1d1c8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

sdk/python/packages/flet-web/src/flet_web/fastapi/flet_upload.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ async def handle(self, request: Request):
112112
if self.__max_upload_size and size > self.__max_upload_size:
113113
raise HTTPException(
114114
status_code=status.HTTP_413_REQUEST_ENTITY_TOO_LARGE,
115-
detail="Max upload size exceeded",
115+
detail="Max upload size exceeded: "
116+
f"{self.__max_upload_size} bytes",
116117
)
117118
await f.write(chunk)

sdk/python/packages/flet/src/flet/messaging/session.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ async def __updates_scheduler(self):
346346
# print(f"**** Running effect: {hook} {is_cleanup}")
347347
if hook and hook.setup and not is_cleanup:
348348
hook.cancel()
349+
res = None
349350
if asyncio.iscoroutinefunction(hook.setup):
350351
hook._setup_task = asyncio.create_task(hook.setup())
351352
else:

0 commit comments

Comments
 (0)