Website Migration Notice: SafePoint is now operated by CyberServal.Learn more →
DiscussionSLA

[Bug] RuntimeError: Received request before initialization was complete

Published a year ago

# Github Issue

Published a year ago

profile_photo

HZJprince

Updated a year ago

0

What happened?

模型是本地 vllm启动的 Qwen2.5-7B-Instruct
客户端是 cherry studio
调用 WAF的mcp功能时,后台出现以下报错:
INFO: 192.168.191.136:11116 - "POST /messages/?session_id=4f90997c0636401dbd7debe48ca6d9b9 HTTP/1.1" 202 Accepted

ERROR: Exception in ASGI application

  • Exception Group Traceback (most recent call last):

| File "/usr/local/lib/python3.13/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi

| result = await app( # type: ignore[func-returns-value]

| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

| self.scope, self.receive, self.send

| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



)



^

| File "/usr/local/lib/python3.13/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call

| return await self.app(scope, receive, send)

| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

| File "/usr/local/lib/python3.13/site-packages/starlette/applications.py", line 112, in call

| await self.middleware_stack(scope, receive, send)

| File "/usr/local/lib/python3.13/site-packages/starlette/middleware/errors.py", line 187, in call

| raise exc

| File "/usr/local/lib/python3.13/site-packages/starlette/middleware/errors.py", line 165, in call

| await self.app(scope, receive, _send)

| File "/usr/local/lib/python3.13/site-packages/starlette/middleware/exceptions.py", line 62, in call

| await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)

| File "/usr/local/lib/python3.13/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app

| raise exc

| File "/usr/local/lib/python3.13/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app

| await app(scope, receive, sender)

| File "/usr/local/lib/python3.13/site-packages/starlette/routing.py", line 714, in call

| await self.middleware_stack(scope, receive, send)

| File "/usr/local/lib/python3.13/site-packages/starlette/routing.py", line 734, in app

| await route.handle(scope, receive, send)

| File "/usr/local/lib/python3.13/site-packages/starlette/routing.py", line 288, in handle

| await self.app(scope, receive, send)

| File "/usr/local/lib/python3.13/site-packages/starlette/routing.py", line 76, in app

| await wrap_app_handling_exceptions(app, request)(scope, receive, send)

| File "/usr/local/lib/python3.13/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app

| raise exc

| File "/usr/local/lib/python3.13/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app

| await app(scope, receive, sender)

| File "/usr/local/lib/python3.13/site-packages/starlette/routing.py", line 73, in app

| response = await f(request)

| ^^^^^^^^^^^^^^^^

| File "/app/server.py", line 33, in handle_sse

| async with sse.connect_sse(

| ~~~~~~~~~~~~~~~^

| request.scope, request.receive, request._send

| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

| ) as [read_stream, write_stream]:



^

| File "/usr/local/lib/python3.13/contextlib.py", line 235, in aexit

| await self.gen.athrow(value)

| File "/usr/local/lib/python3.13/site-packages/mcp/server/sse.py", line 123, in connect_sse

| async with anyio.create_task_group() as tg:

| ~~~~~~~~~~~~~~~~~~~~~~~^^

| File "/usr/local/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 772, in aexit

| raise BaseExceptionGroup(

| "unhandled errors in a TaskGroup", self._exceptions

| ) from None

| ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)

+-+---------------- 1 ----------------

| Exception Group Traceback (most recent call last):

|   File "/usr/local/lib/python3.13/site-packages/mcp/server/sse.py", line 131, in connect_sse

|     yield (read_stream, write_stream)

|   File "/app/server.py", line 36, in handle_sse

|     await mcp_server.run(

|         read_stream, write_stream, mcp_server.create_initialization_options()

|     )

|   File "/usr/local/lib/python3.13/site-packages/mcp/server/lowlevel/server.py", line 483, in run

|     async with AsyncExitStack() as stack:

|                ~~~~~~~~~~~~~~^^

|   File "/usr/local/lib/python3.13/contextlib.py", line 768, in __aexit__

|     raise exc

|   File "/usr/local/lib/python3.13/contextlib.py", line 751, in __aexit__

|     cb_suppress = await cb(*exc_details)

|                   ^^^^^^^^^^^^^^^^^^^^^^

|   File "/usr/local/lib/python3.13/site-packages/mcp/shared/session.py", line 210, in __aexit__

|     return await self._task_group.__aexit__(exc_type, exc_val, exc_tb)

|            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

|   File "/usr/local/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 772, in __aexit__

|     raise BaseExceptionGroup(

|         "unhandled errors in a TaskGroup", self._exceptions

|     ) from None

| ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)

+-+---------------- 1 ----------------

  | Traceback (most recent call last):

  |   File "/usr/local/lib/python3.13/site-packages/mcp/shared/session.py", line 324, in _receive_loop

  |     await self._received_request(responder)

  |   File "/usr/local/lib/python3.13/site-packages/mcp/server/session.py", line 163, in _received_request

  |     raise RuntimeError(

  |         "Received request before initialization was complete"

  |     )

  | RuntimeError: Received request before initialization was complete

  +------------------------------------

How we reproduce?

  1. ...
  2. ...
  3. ...

Expected behavior

No response

Error log

No response

[Bug] RuntimeError: Received request before initialization was complete | CyberServal | CyberServal