Skip to content

Commit 3bb457b

Browse files
fix(application): check returned state before updating app state
- Add a check for the returned state from the lifespan context manager - Only update the app state if there is a returned state - Prevents potential errors when updating state with None or empty values
1 parent 6916182 commit 3bb457b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

nexios/application.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ async def handle_lifespan(self, receive: Receive, send: Send) -> None:
278278
# If a lifespan context manager is provided, use it
279279
self.lifespan_manager: Any = self.lifespan_context(self)
280280
returned_state = await self.lifespan_manager.__aenter__()
281-
self.state.update(returned_state)
281+
if returned_state:
282+
self.state.update(returned_state)
282283
else:
283284
# Otherwise, fall back to the default startup handlers
284285
await self._startup()

0 commit comments

Comments
 (0)