mirror of
https://github.com/langgenius/dify.git
synced 2026-09-08 11:04:27 +08:00
fix: run user_connect authorization inside Flask app context
Socket.IO event handlers run in plain gevent greenlets without a Flask application context, so the db.session() call added in #38227 raises RuntimeError: Working outside of application context, and every user_connect is rejected as unauthorized. Wrap the authorization call in sio.app.app_context(), matching the existing connect handler.
This commit is contained in:
parent
6540d178c6
commit
4c84c5957d
@ -69,7 +69,8 @@ def handle_user_connect(sid, data):
|
||||
if not workflow_id:
|
||||
return {"msg": "workflow_id is required"}, 400
|
||||
|
||||
result = collaboration_service.authorize_and_join_workflow_room(workflow_id, sid, session=db.session())
|
||||
with sio.app.app_context():
|
||||
result = collaboration_service.authorize_and_join_workflow_room(workflow_id, sid, session=db.session())
|
||||
if not result:
|
||||
return {"msg": "unauthorized"}, 401
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user