Skip to content

[Bug]: Getting error in lifespan and initialization #1135

@Sumeet0803

Description

@Sumeet0803

Prerequisites

  • I have searched the existing issues to make sure this bug has not already been reported.
  • I have checked the README for relevant information.

Bug Description

Initial server startup looks good, getting all expected logs. Initial lifespan and initialization looks good and I can see the expected details in the logs.

But while subsequent initializations it randomly throws error:
File "/app/.venv/lib/python3.10/site-packages/mcp/server/streamable_http_manager.py", line 137, in handle_request
raise RuntimeError("Task group is not initialized. Make sure to use run().")
RuntimeError: Task group is not initialized. Make sure to use run().

Sometimes failing in lifespan:
ERROR - mcp-atlassian.server.main - Error during lifespan: unhandled errors in a TaskGroup (1 sub-exception)

  • Exception Group Traceback (most recent call last):
    | File "/app/.venv/lib/python3.10/site-packages/mcp_atlassian/servers/main.py", line 88, in main_lifespan
    | yield {"app_lifespan_context": app_context}
    | File "/app/.venv/lib/python3.10/site-packages/fastmcp/server/server.py", line 97, in wrap
    | yield context
    | File "/usr/local/lib/python3.10/contextlib.py", line 697, in aexit
    | cb_suppress = await cb(*exc_details)
    | File "/app/.venv/lib/python3.10/site-packages/mcp/shared/session.py", line 218, in aexit
    | return await self._task_group.aexit(exc_type, exc_val, exc_tb)
    | File "/app/.venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 772, in aexit
    | raise BaseExceptionGroup(
    | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    | File "/app/.venv/lib/python3.10/site-packages/mcp/server/session.py", line 136, in _receive_loop
    | await super()._receive_loop()
    | File "/app/.venv/lib/python3.10/site-packages/mcp/shared/session.py", line 336, in _receive_loop
    | async for message in self._read_stream:
    | File "/app/.venv/lib/python3.10/site-packages/anyio/abc/_streams.py", line 35, in anext
    | return await self.receive()
    | File "/app/.venv/lib/python3.10/site-packages/anyio/streams/memory.py", line 111, in receive
    | return self.receive_nowait()
    | File "/app/.venv/lib/python3.10/site-packages/anyio/streams/memory.py", line 93, in receive_nowait
    | raise ClosedResourceError
    | anyio.ClosedResourceError

Steps to Reproduce

  1. Starting the server using transport as streamable-http
  2. Check server startup logs
  3. Auto initialization happens successfully
  4. Then randomly fails for subsequent initializations

Expected Behavior

I expected successful initializations every time. Initial initializations are successful but later its failing randomly on its own or when I call from remote, using Curl or custom script

Actual Behavior

Initialization should be successful for every call, it used to work fine sometime back.

mcp-atlassian Version

0.11.9

Installation Method

From source (git clone)

Operating System

Linux (Specify distribution below if relevant)

Python Version

3.10

Atlassian Instance Type

Jira Server / Data Center

Client Application

Custom script

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions