Skip to content

Concurrent map access panic in prepareEvent during websocket send #343

@d-curtis

Description

@d-curtis

Describe the bug
Nexus crashes with "fatal error: concurrent map iteration and map write"
when publishing events while simultaneously sending messages to clients.

To Reproduce
Unfortunately don't have a minimal repro just yet, this happens intermittently in a large stack, I can work on trying to isolate this further if needed, but hopefully the log file provides enough of an indication?

Expected behavior
deepcopying any shared data / synchronizing read/writes to avoid this panic

Environment (please complete the following information):

  • MacOS 15.7.3
  • Nexus Router version 3.3.0
  • WAMP Client - Autobahn Python version 24.4.2
  • Heavy Publish traffic with multiple subscribers

Additional context
I'm not super familiar with go stack traces to be able to hunt down the root cause, so I might be interpreting this log wrong. My best guess (admittedly with a little help from our AI overlords) is there's a race condition when:

  1. Client publishes event with Arguments/ArgumentsKw map
  2. Broker's prepareEvent/trySend modifies this map (adding metadata)
  3. Simultaneously, websocket transport serializes the same map to JSON
  4. No defensive copy is made before either operation

I've attached the stdout/err log from nexusd.
I noticed something similar in #322 - I had this issue previously with Nexus v3.2.2, but it looks like this update to 3.3.0 hasn't addressed this specific crash.

Just want to say thank you for your hard work on this, I'm currently working on moving away from a different router and so far been super impressed with the performance and portability of Nexus, it's been mostly painless to switch over so far.

Please let me know if there's any more info I can provide or any further troubleshooting to try. Cheers!

_nexus.log

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