Skip to content

WebSocket write callback serves incorrect chunk sizes for large messages #22413

Description

@HendrikHuebner

I did this

A few weeks ago I reported #22273, which was resolved by #22283.

Unfortunately, I think the issue is not fully fixed. I am still seeing mismatched chunk sizes in my application, where curl_ws_meta()->len does not equal nmemb (the number of bytes served to the write callback). The issue now only reproduces for large messages, which are broken up into smaller chunks by curl.

I attached a new reproducer below. Similarly to the old reproducer, it sends multiple messages while the receiver pauses occasionally. The messages are 64kiB. The first message seems to be enough to trigger the bug already, but my reproducer still contains multiple messages. Logs:

callback #1 bytes=4086
meta age=0 flags=0x2 offset=0 bytesleft=61450 len=4086
returning CURL_WRITEFUNC_PAUSE
unpause #1 with curl_easy_pause(..., CURLPAUSE_CONT)
callback #2 bytes=8182
meta age=0 flags=0x2 offset=4086 bytesleft=57354 len=4096
FAIL callback bytes=8182 differs from meta len=4096 seq=1
FAIL curl_easy_pause returned 23 (Failed writing received data to disk/application)                         

server.py

client.c

I expected the following

The buffer size served to the write callback should match the chunk size in the websocket meta data struct.

curl/libcurl version

Curl was built from source at 27a4557c9ea87f1961741fb728387261387b398c (committed on 27.7.2026).

operating system

macOS 26.3, Darwin 25.3.0 on arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions