ArchiveBox / ArchiveBox/abxbus
Recursion issue in Python Redis Bridge
- Dominant language
- Rust
- Stars
- 12
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
I'm getting a recursion issue in Python when receiving an event from Typescript over the Redis Bridge. I have both cross wired with the Redis Bridge, see code below. These are running on Docker images
**python:3.13-slim**
python: 3.13
abxbus: 2.5.6
redis: 7.4.0
**node:25-slim**
typescript: 6.0.3
abxbus: 2.5.6
ioredis: 5.10.1
zod: 4.4.2
Python:
```python
async def handle(event: BaseEvent[Any]) -> None:
print(f"Received:\tType: {event.event_type}\tID: {event.event_id}")
async def main():
bus.on("*", bridge.emit)
bridge.on("*", bus.emit)
bus.on("*", handle)
await asyncio.Future() # Wait forever
if __name__ == "__main__":
asyncio.run(main())
```
Typescript:
```typescript
const handle = async (event: BaseEvent) => {
console.log(`Received:\tType: ${event.event_type}\tID: ${event.event_id}`)
}
const FrontendEvent = BaseEvent.extend('FrontendEvent', {
message: z.string(),
})
bus.on('*', bridge.emit)
bridge.on('*', bus.emit)
bus.on('*', handle)
async function main() {
// Emit a test event inline
await sleep(4000)
await bus.emit(FrontendEvent({ message: 'Hello from Frontend!' }))
await new Promise(() => {}) // Wait forever
}
main().catch(console.error)
```
When running, the event is emitted from the TypeScript( frontend-1) and its handler picks up the event. The event is sent over the Redis bridge to Python(backend-1) and the event bus. It looks like the cross wiring on the Python side is trying to emit the event back to the bridge and the Redis Bridge is catching it and throwing the error:
```log
frontend-1 | Received: Type: FrontendEvent ID: 019e4348-9f25-70b3-98ba-8cd09ea06572
backend-1 | ❌ EventBus#2585🟢(queue=0 active=1 history=1 handlers=2) Error in event handler RedisEventBridge.emit(EventBus#2585▶ FrontendEvent#86a5 🏃) ->
backend-1 | PydanticSerializationError(Error calling function `event_result_type_serializer`: RecursionError)
backend-1 | pydantic_core._pydantic_core.PydanticSerializationError: Error calling function `event_result_type_serializer`: RecursionError
backend-1 |
backend-1 | Received: Type: FrontendEvent ID: 06a0d20e-d633-7edf-8000-e7ac577686a5
```
If I comment out `python bus.on("*", bridge.emit)`, the error is not thrown.
If you need more information, please let me know.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the issue with the shown Python and TypeScript handlers using the listed Docker images and versions. Start at the cross-wired bus.on("*", bridge.emit) and bridge.on("*", bus.emit) entry points, then follow the Pydantic serialization traceback. Done means events can cross the Redis bridge without recursive emission or RecursionError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python, redis, typescript
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100