medusa icon indicating copy to clipboard operation
medusa copied to clipboard

WebSocket/Server sent events implementation

Open kasperkristensen opened this issue 2 years ago • 1 comments

We want to implement some notion of server transmitted data, as we want to be able to transmit to the client when a batch job is completed, and as an example notify that a file is now ready to be downloaded. Should expandable upon later, such as pushing a notification when a user is mentioned in a comment on an order, etc.

Part of this ticket is investigating how we should approach this, as WebSocket/SSE is not very "RESTy". One idea would be to subscribe to an event, and when detected push to the client "you should GET /admin/batch/<some_id>", to keep it slim and still make use of the existing RESTFUL API.


  • https://github.com/medusajs/medusa-engineering/issues/152

kasperkristensen avatar Mar 29 '22 07:03 kasperkristensen

In general, it is better to do what you said which is

  • Client action
  • Server process
  • Server send event to client to fetch specific resources

One point in favour of that is that the socket does not transmit any data (simple security, response consistency)

adrien2p avatar May 23 '22 09:05 adrien2p

Since this issue is closed, can i know if this websocket feature is added for medusa js backend or not? Cuz the project im using this medusajs is quite depend on this server sent events.. if there is support to add our own websocket server or any port defaulty serves this websocket server by medusa, i would like to know the references please... thanks

shivapasunuri avatar Nov 22 '23 05:11 shivapasunuri