Skip to content

Add _corkUnsafe and _uncorkUnsafe to WebSocket and HttpResponse wrappers#1244

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/add-uncork-cork-functions
Draft

Add _corkUnsafe and _uncorkUnsafe to WebSocket and HttpResponse wrappers#1244
Copilot wants to merge 3 commits intomasterfrom
copilot/add-uncork-cork-functions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 15, 2026

Exposes direct cork/uncork on the underlying AsyncSocket for both WebSocket and HttpResponse, bypassing the safe callback-based cork() API for advanced use cases requiring manual cork state management.

Changes

  • AsyncSocketCorkHelper<bool SSL> — thin helper struct inheriting uWS::AsyncSocket<SSL> to expose the protected cork() and uncork() methods; guarded with #ifndef UWS_JS_ASYNC_SOCKET_CORK_HELPER_DEFINED to prevent ODR violations when both wrapper headers are compiled in the same TU
  • WebSocketWrapper — adds uWS_WebSocket_corkUnsafe / uWS_WebSocket_uncorkUnsafe, registered as _corkUnsafe / _uncorkUnsafe
  • HttpResponseWrapper — adds res_corkUnsafe / res_uncorkUnsafe, registered in the if constexpr (SSL != 2) block (same scope as cork; excludes QUIC/CACHE); uses SSL != 0 to map int PROTOCOLbool SSL for the cast
  • docs/index.d.ts — adds typed declarations for both interfaces with warnings about mandatory pairing

Usage

// Manual cork/uncork without callback overhead
ws._corkUnsafe();
ws.send(data1);
ws.send(data2);
ws._uncorkUnsafe();

res._corkUnsafe();
res.writeStatus('200 OK').writeHeader('Content-Type', 'text/plain').end('hello');
res._uncorkUnsafe();

⚠️ _corkUnsafe must always be paired with _uncorkUnsafe. Failing to uncork leaves the socket in a permanently corked state and prevents data from being flushed.


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

…eWrapper

Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com>
Copilot AI changed the title [WIP] Add uncorkUnsafe and corkUnsafe functions for wrappers Add _corkUnsafe and _uncorkUnsafe to WebSocket and HttpResponse wrappers Mar 15, 2026
Copilot AI requested a review from uNetworkingAB March 15, 2026 10:52
Copy link
Copy Markdown

@ronag ronag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add fast api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants