Skip to content

TypeError in InstrumentedAsyncServer for missing argument 'reason' #1425

@AlexLardschneider

Description

@AlexLardschneider

Describe the bug
When enabling instrumentation / admin mode, on client disconnect, I can see the following stack trace coming from python-socketio after ugprading to version 5.12.0.

disconnect async handler error
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/engineio/async_server.py", line 509, in run_async_handler
    return await self.handlers[event](*args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: InstrumentedAsyncServer._handle_eio_disconnect() takes 2 positional arguments but 3 were given

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/engineio/async_server.py", line 515, in run_async_handler
    return await self.handlers[event](args[0])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/socketio/async_admin.py", line 297, in _handle_eio_disconnect
    return await self.sio._handle_eio_disconnect(eio_sid)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: AsyncServer._handle_eio_disconnect() missing 1 required positional argument: 'reason'

I believe that this is related to the changes introduced in #1422, since earlier versions do not have this issue.

Also, disabling instrumentation does seem to resolve this issue.

To Reproduce
Upgrade python-socketio to version 5.12.0, and enable instrumentation:

SOCKETIO.instrument(auth={
    'username': "admin",
    'password': "admin",
})

Expected behavior
The reason parameter should be passed to AsyncServer even if instrumentation is enabled and InstrumentedAsyncServer is used.

Logs
See stack trace above.

Additional context
Used together with AioHTTP web server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions