Skip to content

fix: add missing return after no-worker error in controller stream generator#3790

Open
alvinttang wants to merge 1 commit intolm-sys:mainfrom
alvinttang:fix/controller-missing-return-no-worker
Open

fix: add missing return after no-worker error in controller stream generator#3790
alvinttang wants to merge 1 commit intolm-sys:mainfrom
alvinttang:fix/controller-missing-return-no-worker

Conversation

@alvinttang
Copy link

Summary

  • In Controller.worker_api_generate_stream(), when no worker is available for the requested model, the code yields an error response but does not return from the generator. This causes execution to fall through into the try block, which attempts a POST request to an empty URL ("" + "/worker_generate_stream"), raising a MissingSchema/ConnectionError. That exception is caught and a second, misleading "worker timeout" error is yielded to the client.
  • Adding return after the no-worker yield ensures the generator terminates cleanly with only the correct error message.

How to reproduce

  1. Start a controller with no workers registered
  2. Send a /worker_generate_stream request to the controller
  3. Observe that the client receives two error chunks instead of one: first the "no worker" error, then a spurious "worker timeout" error

Test plan

  • Verified the fix by reading the control flow — yield in a generator does not exit the function, so return is required
  • No other callers of handle_no_worker are affected

🤖 Generated with Claude Code

In Controller.worker_api_generate_stream(), when no worker is available
for the requested model, the code yields an error response but does not
return. This causes it to fall through and attempt a POST request to an
empty worker address ("" + "/worker_generate_stream"), which raises a
MissingSchema or ConnectionError exception. The exception is then caught
and a misleading "worker timeout" error is yielded as a second response.

Adding a return statement after the no-worker yield ensures the generator
terminates cleanly with the correct error message.
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.

1 participant