svelte-adapter-uws 0.2.13 → 0.2.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/README.md +1 -1
- package/files/handler.js +13 -11
- package/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -352,7 +352,7 @@ adapter({
|
|
|
352
352
|
// Automatically send pings to keep the connection alive
|
|
353
353
|
sendPingsAutomatically: true, // default: true
|
|
354
354
|
|
|
355
|
-
// Seconds before an async upgrade handler is rejected with 504
|
|
355
|
+
// Seconds before an async upgrade handler is rejected with 504 (0 to disable)
|
|
356
356
|
upgradeTimeout: 10, // default: 10
|
|
357
357
|
|
|
358
358
|
// Allowed origins for WebSocket connections
|
package/files/handler.js
CHANGED
|
@@ -869,18 +869,20 @@ if (WS_ENABLED) {
|
|
|
869
869
|
|
|
870
870
|
const cookies = parseCookies(headers['cookie']);
|
|
871
871
|
|
|
872
|
-
const upgradeTimeoutMs = (wsOptions.upgradeTimeout || 10) * 1000;
|
|
873
872
|
let timedOut = false;
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
res.
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
873
|
+
let timer;
|
|
874
|
+
if (wsOptions.upgradeTimeout > 0) {
|
|
875
|
+
timer = setTimeout(() => {
|
|
876
|
+
timedOut = true;
|
|
877
|
+
if (!aborted) {
|
|
878
|
+
res.cork(() => {
|
|
879
|
+
res.writeStatus('504 Gateway Timeout');
|
|
880
|
+
res.writeHeader('content-type', 'text/plain');
|
|
881
|
+
res.end('Upgrade timed out');
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
}, wsOptions.upgradeTimeout * 1000);
|
|
885
|
+
}
|
|
884
886
|
|
|
885
887
|
Promise.resolve(wsModule.upgrade({ headers, cookies, url, remoteAddress }))
|
|
886
888
|
.then((userData) => {
|
package/index.d.ts
CHANGED
|
@@ -154,7 +154,7 @@ export interface WebSocketOptions {
|
|
|
154
154
|
/**
|
|
155
155
|
* Timeout in seconds for async `upgrade` handlers.
|
|
156
156
|
* If the upgrade hook doesn't resolve within this time, the connection
|
|
157
|
-
* is rejected with 504 Gateway Timeout.
|
|
157
|
+
* is rejected with 504 Gateway Timeout. Set to `0` to disable.
|
|
158
158
|
* @default 10
|
|
159
159
|
*/
|
|
160
160
|
upgradeTimeout?: number;
|
package/package.json
CHANGED