svelte-adapter-uws 0.4.13 → 0.4.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/files/handler.js CHANGED
@@ -1653,7 +1653,9 @@ if (WS_ENABLED) {
1653
1653
  // no cookie parsing). Inject remoteAddress so plugins/ratelimit can
1654
1654
  // key on the real client IP via ws.getUserData().remoteAddress.
1655
1655
  if (!wsModule.upgrade) {
1656
- res.upgrade({ remoteAddress: clientIp }, secKey, secProtocol, secExtensions, context);
1656
+ res.cork(() => {
1657
+ res.upgrade({ remoteAddress: clientIp }, secKey, secProtocol, secExtensions, context);
1658
+ });
1657
1659
  return;
1658
1660
  }
1659
1661
 
@@ -1723,23 +1725,25 @@ if (WS_ENABLED) {
1723
1725
  }
1724
1726
  const ud = userData || {};
1725
1727
  if (!ud.remoteAddress) ud.remoteAddress = clientIp;
1726
- if (responseHeaders) {
1727
- maybeWarnSetCookieOnUpgrade(responseHeaders);
1728
- for (const [hk, hv] of Object.entries(responseHeaders)) {
1729
- if (Array.isArray(hv)) {
1730
- for (const v of hv) res.writeHeader(hk, v);
1731
- } else {
1732
- res.writeHeader(hk, hv);
1728
+ if (responseHeaders) maybeWarnSetCookieOnUpgrade(responseHeaders);
1729
+ res.cork(() => {
1730
+ if (responseHeaders) {
1731
+ for (const [hk, hv] of Object.entries(responseHeaders)) {
1732
+ if (Array.isArray(hv)) {
1733
+ for (const v of hv) res.writeHeader(hk, v);
1734
+ } else {
1735
+ res.writeHeader(hk, hv);
1736
+ }
1733
1737
  }
1734
1738
  }
1735
- }
1736
- res.upgrade(
1737
- ud,
1738
- secKey,
1739
- secProtocol,
1740
- secExtensions,
1741
- context
1742
- );
1739
+ res.upgrade(
1740
+ ud,
1741
+ secKey,
1742
+ secProtocol,
1743
+ secExtensions,
1744
+ context
1745
+ );
1746
+ });
1743
1747
  })
1744
1748
  .catch((err) => {
1745
1749
  clearTimeout(timer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-adapter-uws",
3
- "version": "0.4.13",
3
+ "version": "0.4.14",
4
4
  "description": "SvelteKit adapter for uWebSockets.js - high-performance C++ HTTP server with built-in WebSocket support",
5
5
  "author": "Kevin Radziszewski",
6
6
  "license": "MIT",
package/testing.js CHANGED
@@ -115,7 +115,9 @@ export async function createTestServer(options = {}) {
115
115
  const rawIp = new TextDecoder().decode(res.getRemoteAddressAsText());
116
116
 
117
117
  if (!handler.upgrade) {
118
- res.upgrade({ remoteAddress: rawIp }, secKey, secProtocol, secExtensions, context);
118
+ res.cork(() => {
119
+ res.upgrade({ remoteAddress: rawIp }, secKey, secProtocol, secExtensions, context);
120
+ });
119
121
  return;
120
122
  }
121
123
 
@@ -143,16 +145,18 @@ export async function createTestServer(options = {}) {
143
145
  userData = result || {};
144
146
  }
145
147
  if (!userData.remoteAddress) userData.remoteAddress = rawIp;
146
- if (responseHeaders) {
147
- for (const [hk, hv] of Object.entries(responseHeaders)) {
148
- if (Array.isArray(hv)) {
149
- for (const v of hv) res.writeHeader(hk, v);
150
- } else {
151
- res.writeHeader(hk, hv);
148
+ res.cork(() => {
149
+ if (responseHeaders) {
150
+ for (const [hk, hv] of Object.entries(responseHeaders)) {
151
+ if (Array.isArray(hv)) {
152
+ for (const v of hv) res.writeHeader(hk, v);
153
+ } else {
154
+ res.writeHeader(hk, hv);
155
+ }
152
156
  }
153
157
  }
154
- }
155
- res.upgrade(userData, secKey, secProtocol, secExtensions, context);
158
+ res.upgrade(userData, secKey, secProtocol, secExtensions, context);
159
+ });
156
160
  })
157
161
  .catch((err) => {
158
162
  if (!aborted) {