Skip to content

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

@jeffquach

Description

@jeffquach

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

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