Skip to content

Conversation

@ekzhang
Copy link
Contributor

@ekzhang ekzhang commented May 14, 2025

Hi — I was debugging a customer issue for work at Modal (modal.com) and discovered that the python engine.io implementation behaves slightly differently from the ASGI spec, which suggests that:

Exactly one of bytes or text must be non-None. One or both keys may be present, however.

The Python engineio client fails connection on Modal currently because it gets a dict:

{'type': 'websocket.send', 'bytes': None, 'text': '40{"sid":"gK4jeac7mjv1pc6kAAAB"}'}

But it checks for presence with 'bytes' in event, rather than event.get('bytes') is not None.

This is a quick fix for the issue — let me know if this makes sense or if you'd want me to help add a test as well!

Hi — I were debugging a customer issue for work at Modal (modal.com) and discovered that the python engine.io implementation behaves slightly differently from the ASGI spec, which suggests that:

> Exactly one of bytes or text must be non-None. One or both keys may be present, however.

The Python engineio client fails connection on Modal currently because it gets a dict:

```
{'type': 'websocket.send', 'bytes': None, 'text': '40{"sid":"gK4jeac7mjv1pc6kAAAB"}'}
```

But it checks for presence with `'bytes' in event`, rather than `event.get('bytes') is not None`.

This is a quick fix for the issue — let me know if this makes sense or if you'd want me to help add a test as well!
ekzhang added a commit to modal-labs/modal-client that referenced this pull request May 14, 2025
The python-engineio library has a small bug in its ASGI server implementation, which I reported here miguelgrinberg/python-engineio#405

Anyway we can also make the Modal client send messages in a way that doesn't trigger this bug.
ekzhang added a commit to modal-labs/modal-client that referenced this pull request May 14, 2025
The python-engineio library has a small bug in its ASGI server implementation, which I reported here miguelgrinberg/python-engineio#405

Anyway we can also make the Modal client send messages in a way that doesn't trigger this bug.
@miguelgrinberg miguelgrinberg merged commit 86cb4d2 into miguelgrinberg:main May 15, 2025
21 of 22 checks passed
@miguelgrinberg
Copy link
Owner

LGTM. Thanks!

@ekzhang ekzhang deleted the patch-1 branch May 15, 2025 13:09
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.

2 participants