socketify.py icon indicating copy to clipboard operation
socketify.py copied to clipboard

Using cork_send or send to send JSON causes socketify to infinitely hang when trying to JSON serialize a datetime object

Open jeffquach opened this issue 11 months ago • 0 comments

Describe the bug Using cork_send or send to send JSON causes socketify to infinitely hang when trying to JSON serialize a datetime object.

To Reproduce Steps to reproduce the behavior:

  1. Run this sample code:
from socketify import App
import datetime

async def test(res, req):
    data = [(586.9000244140625, 0, datetime.datetime(2025, 3, 1, 13, 29, 10)), (587.0, 644, datetime.datetime(2025, 3, 1, 13, 29, 10))]
    res.cork_send(data, content_type=b"application/json")

def run(app: App):
    app.get("/test", test)
  1. Go to your browser and load: localhost:3000/test
  2. No response is produced and the browser tab infinitely spins/hangs.

Expected behavior JSON should be sent back or there should be an error thrown by socketify rather than having no output.

Desktop (please complete the following information):

  • OS: Ubuntu 24.04
  • Browser: Brave (Chromium)
  • Version: v1.75.181

jeffquach avatar Mar 02 '25 17:03 jeffquach