Charles Yao and Claude Opus 4.8
2b4df02305
fix(dify_builder): close SSE subscription even when the response is never iterated
...
progress_bus.subscribe() eagerly enters the pub/sub subscription (opening a
Redis connection + starting a listener thread) BEFORE the SSE generator
exists, so the subscribe completes before the Celery advance can publish.
But the only close() lived in the generator's finally -- which Python does
not run if the generator is never started. A streaming Response dropped
before its first frame (client aborted, or an after_request/teardown error)
therefore leaked the connection + thread until process restart.
stream_advance_frames now returns a small _ClosingFrameStream wrapper whose
close() closes the subscription directly (idempotent); the WSGI server calls
close() on the response iterable even on early disconnect, so cleanup fires
regardless of iteration. The inner generator keeps its own finally for the
iterated/disconnect paths, so this is strictly additive -- no happy-path
change. All seven call sites get it unchanged.
Adds a regression test (never-iterated stream -> close() -> subscription closed).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com >
2026-09-03 08:48:23 +08:00
..
2026-08-31 05:57:40 +00:00
2026-08-18 04:30:17 +00:00
2026-08-29 14:05:35 +00:00
2026-09-03 08:48:23 +08:00
2026-08-31 03:33:09 +00:00
2026-08-18 12:01:49 +00:00
2026-08-21 06:09:39 +00:00
2026-08-29 14:06:07 +00:00
2026-08-27 02:41:43 +00:00
2026-08-29 14:05:34 +00:00
2026-08-29 14:06:07 +00:00
2026-08-29 14:05:34 +00:00
2026-08-11 07:39:01 +00:00
2026-08-11 06:19:08 +00:00
2026-08-27 08:51:05 +00:00
2026-08-27 08:51:05 +00:00
2026-08-21 05:56:30 +00:00
2026-08-21 05:56:30 +00:00
2026-08-25 01:48:12 +00:00
2026-08-21 08:13:23 +00:00
2026-08-21 08:13:23 +00:00
2026-08-21 08:13:23 +00:00
2026-08-21 08:46:06 +00:00
2026-08-21 08:05:43 +00:00
2026-08-25 01:48:12 +00:00
2026-08-31 03:22:01 +00:00
2026-08-31 03:22:01 +00:00
2026-08-26 07:14:27 +00:00
2026-08-21 08:05:43 +00:00
2026-08-21 05:56:30 +00:00
2026-08-21 05:56:30 +00:00
2026-08-21 05:56:30 +00:00
2026-08-20 05:03:08 +00:00
2026-08-31 02:51:19 +00:00
2026-08-29 14:05:34 +00:00
2026-08-29 14:05:34 +00:00
2026-08-25 10:21:32 +00:00
2026-08-21 06:09:26 +00:00
2026-08-20 05:11:46 +00:00
2026-08-19 07:23:47 +00:00
2026-08-29 14:06:07 +00:00
2026-08-29 14:05:35 +00:00
2026-08-31 09:30:52 +00:00
2026-08-18 12:23:33 +00:00
2026-08-29 14:05:34 +00:00
2026-08-26 06:31:06 +00:00
2026-08-18 12:01:49 +00:00
2026-08-20 05:11:46 +00:00
2026-08-25 10:21:32 +00:00
2026-08-11 07:39:01 +00:00
2026-08-24 01:55:48 +00:00
2026-08-26 06:32:13 +00:00
2026-08-28 14:47:16 +00:00
2026-08-28 14:47:16 +00:00
2026-08-26 06:32:13 +00:00
2026-08-18 12:01:49 +00:00
2026-08-18 12:26:01 +00:00
2026-08-28 14:47:16 +00:00
2026-08-26 07:33:37 +00:00
2026-08-28 14:47:17 +00:00
2026-08-29 14:05:34 +00:00
2026-08-31 05:55:38 +00:00
2026-08-29 14:05:34 +00:00
2026-08-18 12:01:29 +00:00
2026-08-11 07:39:01 +00:00
2026-08-11 07:39:01 +00:00
2026-08-29 14:05:35 +00:00
2026-08-18 12:23:33 +00:00
2026-08-12 07:45:39 +00:00
2026-08-24 06:35:42 +00:00
2026-08-07 00:42:55 +00:00
2026-08-28 14:47:16 +00:00
2026-08-29 14:05:35 +00:00
2026-08-23 12:38:04 -07:00
2026-08-11 07:39:01 +00:00
2026-08-28 14:47:16 +00:00
2026-08-24 06:35:42 +00:00
2026-08-28 14:47:16 +00:00
2026-08-28 14:47:16 +00:00
2026-08-28 14:47:16 +00:00
2026-08-28 14:47:16 +00:00
2026-08-28 14:47:16 +00:00
2026-08-28 14:47:16 +00:00
2026-08-28 14:47:16 +00:00
2026-08-28 14:47:16 +00:00
2026-08-25 10:26:06 +00:00
2026-08-11 07:39:01 +00:00
2026-08-28 14:47:16 +00:00
2026-08-18 12:01:49 +00:00
2026-08-28 14:47:16 +00:00
2026-08-10 03:27:56 +00:00
2026-08-28 14:47:17 +00:00
2026-08-29 14:05:34 +00:00
2026-08-27 12:15:07 +00:00
2026-08-29 14:05:34 +00:00
2026-08-12 08:42:09 +00:00
2026-08-29 14:05:34 +00:00
2026-08-20 05:11:46 +00:00
2026-08-18 12:01:49 +00:00
2026-08-11 16:37:14 +00:00
2026-08-11 16:37:14 +00:00
2026-08-18 12:23:33 +00:00
2026-08-07 00:42:13 +00:00
2026-08-29 14:05:34 +00:00
2026-08-31 04:37:07 +00:00
2026-08-31 04:37:07 +00:00
2026-08-26 07:33:37 +00:00
2026-08-26 07:33:37 +00:00
2026-08-15 09:54:09 +00:00
2026-08-29 14:05:35 +00:00
2026-08-20 13:13:43 +00:00
2026-08-08 11:52:15 +00:00
2026-08-24 01:57:17 +00:00
2026-08-08 11:52:15 +00:00
2026-08-29 14:05:35 +00:00
2026-08-29 14:06:07 +00:00
2026-08-20 05:12:30 +00:00
2026-08-29 14:05:34 +00:00
2026-08-31 04:37:07 +00:00
2026-08-24 05:29:14 +00:00
2026-08-29 14:05:34 +00:00
2026-08-07 09:21:13 +00:00
2026-08-29 14:05:34 +00:00
2026-08-29 14:05:34 +00:00
2026-08-20 05:11:46 +00:00
2026-08-28 14:47:16 +00:00
2026-08-20 05:05:31 +00:00
2026-08-20 02:27:49 +00:00
2026-08-29 14:05:34 +00:00
2026-08-24 04:01:02 +00:00
2026-08-28 14:32:27 +00:00
2026-08-29 14:05:35 +00:00
2026-08-24 03:20:32 +00:00
2026-08-25 10:21:32 +00:00
2026-08-13 05:19:52 +00:00
2026-08-18 12:26:01 +00:00
2026-08-29 14:05:34 +00:00
2026-08-27 02:41:02 +00:00
2026-08-18 12:23:33 +00:00
2026-08-11 07:39:01 +00:00