Skip to content

Commit

Permalink
feat(uWebSockets): Drop deprecated request context extra
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The deprecated uWebSockets `request` context extra field has been dropped because it is stack allocated and cannot be used ouside the internal `upgrade` callback.
  • Loading branch information
enisdenjo committed Jun 8, 2021
1 parent 3c1f13c commit 02ea5ee
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 41 deletions.
16 changes: 0 additions & 16 deletions docs/interfaces/use_uwebsockets.extra.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ The extra that will be put in the `Context`.
### Properties

- [persistedRequest](use_uwebsockets.extra.md#persistedrequest)
- [request](use_uwebsockets.extra.md#request)
- [socket](use_uwebsockets.extra.md#socket)

## Properties
Expand All @@ -40,21 +39,6 @@ while it is accessible.

___

### request

`Readonly` **request**: `HttpRequest`

The initial HTTP request before the actual
socket and connection is established.

**`deprecated`** uWS.HttpRequest is stack allocated and cannot be accessed outside the internal `upgrade` callback. Consider using the `persistedRequest` instead.

#### Inherited from

[UpgradeData](use_uwebsockets.upgradedata.md).[request](use_uwebsockets.upgradedata.md#request)

___

### socket

`Readonly` **socket**: `WebSocket` & [UpgradeData](use_uwebsockets.upgradedata.md)
Expand Down
12 changes: 0 additions & 12 deletions docs/interfaces/use_uwebsockets.upgradedata.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Data acquired during the HTTP upgrade callback from uWS.
### Properties

- [persistedRequest](use_uwebsockets.upgradedata.md#persistedrequest)
- [request](use_uwebsockets.upgradedata.md#request)

## Properties

Expand All @@ -32,14 +31,3 @@ uWS's request is stack allocated and cannot be accessed
from outside of the internal upgrade; therefore, the persisted
request holds the relevant values extracted from the uWS's request
while it is accessible.

___

### request

`Readonly` **request**: `HttpRequest`

The initial HTTP request before the actual
socket and connection is established.

**`deprecated`** uWS.HttpRequest is stack allocated and cannot be accessed outside the internal `upgrade` callback. Consider using the `persistedRequest` instead.
3 changes: 0 additions & 3 deletions src/tests/use.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ for (const { tServer, startTServer } of tServers) {
expect((ctx.extra as UWSExtra).socket.constructor.name).toEqual(
'uWS.WebSocket',
);
expect((ctx.extra as UWSExtra).request.constructor.name).toEqual(
'uWS.HttpRequest',
);
expect((ctx.extra as UWSExtra).persistedRequest.method).toBe(
'get',
);
Expand Down
11 changes: 1 addition & 10 deletions src/use/uWebSockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ export interface Extra extends UpgradeData {
* @category Server/uWebSockets
*/
export interface UpgradeData {
/**
* The initial HTTP request before the actual
* socket and connection is established.
*
* @deprecated uWS.HttpRequest is stack allocated and cannot be accessed outside the internal `upgrade` callback. Consider using the `persistedRequest` instead.
*/
readonly request: uWS.HttpRequest;
/**
* The initial HTTP upgrade request before the actual
* socket and connection is established.
Expand Down Expand Up @@ -119,7 +112,6 @@ export function makeBehavior<

res.upgrade<UpgradeData>(
{
request: req,
persistedRequest: {
method: req.getMethod(),
url: req.getUrl(),
Expand Down Expand Up @@ -169,8 +161,7 @@ export function makeBehavior<
},
onMessage: (cb) => (client.handleMessage = cb),
},
{ socket, request: socket.request, persistedRequest } as Extra &
Partial<E>,
{ socket, persistedRequest } as Extra & Partial<E>,
);

if (keepAlive > 0 && isFinite(keepAlive)) {
Expand Down

0 comments on commit 02ea5ee

Please sign in to comment.