Repository navigation
fix(api): avoid duplicate streaming app concurrency admission - #45038
Merged
hjlarry merged 1 commit intoOct 29, 2026
Merged
Conversation
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-10-29 06:31:22.901856069 +0000
+++ /tmp/pyrefly_pr.txt 2026-10-29 06:31:12.229742607 +0000
@@ -6005,17 +6005,17 @@
ERROR Argument `Literal['app']` is not assignable to parameter `value` with type `ApiTokenType | SQLCoreOperations[ApiTokenType]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
--> tests/unit_tests/services/test_api_token_service.py:323:30
ERROR Argument `AppMode | str` is not assignable to parameter `mode` with type `AppMode | SQLCoreOperations[AppMode]` in function `models.model.App.__init__` [bad-argument-type]
- --> tests/unit_tests/services/test_app_generate_service.py:84:14
+ --> tests/unit_tests/services/test_app_generate_service.py:87:14
ERROR Class member `_TrackingRateLimit.exit` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
- --> tests/unit_tests/services/test_app_generate_service.py:738:21
+ --> tests/unit_tests/services/test_app_generate_service.py:824:21
ERROR Class member `_TrackingRateLimit.exit` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
- --> tests/unit_tests/services/test_app_generate_service.py:774:21
+ --> tests/unit_tests/services/test_app_generate_service.py:860:21
ERROR Class member `_TrackingRateLimit.exit` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
- --> tests/unit_tests/services/test_app_generate_service.py:808:21
+ --> tests/unit_tests/services/test_app_generate_service.py:894:21
ERROR Argument `_FakeStreams` is not assignable to parameter `redis_client` with type `Redis[Unknown] | RedisCluster[Unknown]` in function `libs.broadcast_channel.redis.streams_channel.StreamsBroadcastChannel.__init__` [bad-argument-type]
- --> tests/unit_tests/services/test_app_generate_service.py:1144:40
+ --> tests/unit_tests/services/test_app_generate_service.py:1230:40
ERROR Argument `_FakeRedisClient` is not assignable to parameter `redis_client` with type `Redis[Unknown] | RedisCluster[Unknown]` in function `libs.broadcast_channel.redis.pubsub_channel.BroadcastChannel.__init__` [bad-argument-type]
- --> tests/unit_tests/services/test_app_generate_service.py:1162:38
+ --> tests/unit_tests/services/test_app_generate_service.py:1248:38
ERROR Argument `str | None` is not assignable to parameter `tenant_id` with type `str` in function `services.app_service.AppService.create_app` [bad-argument-type]
--> tests/unit_tests/services/test_app_service.py:257:17
ERROR Argument `str | None` is not assignable to parameter `tenant_id` with type `str` in function `services.app_service.AppService.create_app` [bad-argument-type]
|
Contributor
Pyrefly Type Coverage
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #45038 +/- ##
==========================================
- Coverage 89.55% 89.55% -0.01%
==========================================
Files 6013 6013
Lines 377225 377215 -10
Branches 76368 76367 -1
==========================================
- Hits 337830 337821 -9
- Misses 33402 33403 +1
+ Partials 5993 5991 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
hjlarry
enabled auto-merge
October 29, 2026 06:53
MRZHUH
approved these changes
Oct 29, 2026
hjlarry
added a commit
that referenced
this pull request
Oct 29, 2026
(cherry picked from commit 2626b79)
1 task done
3 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #45037.
fix https://linear.app/dify/issue/ENG-1364/bug-workflow-%E5%B9%B6%E5%8F%91%E4%B8%8A%E9%99%90%E4%B8%BA-1-%E6%97%B6%E5%8D%95%E6%AC%A1-test-run-%E8%A2%AB%E5%90%8C%E4%B8%80%E8%AF%B7%E6%B1%82%E7%9A%84%E9%87%8D%E5%A4%8D%E9%99%90%E6%B5%81%E6%A3%80%E6%9F%A5%E6%8B%A6%E6%88%AA
Streaming Workflow and Advanced Chat requests entered the app concurrency limiter twice, so a limit of 1 rejected the only active request. Remove the duplicate admission contexts and keep the slot owned by the outer guard and
RateLimitGeneratoruntil the stream finishes, fails, or closes. Remove the unusedrate_limit_contexthelper and itscontextlibimport.Add regression coverage for both app modes that checks first-request admission, rejection of an overlapping request, slot retention, and admission after normal completion, stream failure, or explicit close.
Validation
test_app_generate_service.pyandcore/app/features/rate_limiting/test_rate_limit.py.DEBUG=false make lintpassed.DEBUG=false make type-checkpassed.Checklist
make lint && make type-checkfor the backend.From Codex