Skip to content

Commit c187e4f

Browse files
authored
Update UpgradeAsync.js (#926)
1 parent 9358393 commit c187e4f

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

‎examples/UpgradeAsync.js‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,19 @@ const app = uWS./*SSL*/App({
3535
return;
3636
}
3737

38-
/* This immediately calls open handler, you must not use res after this call */
39-
res.upgrade({
40-
url: url
41-
},
42-
/* Use our copies here */
43-
secWebSocketKey,
44-
secWebSocketProtocol,
45-
secWebSocketExtensions,
46-
context);
38+
/* Cork any async response including upgrade */
39+
res.cork(() => {
40+
/* This immediately calls open handler, you must not use res after this call */
41+
res.upgrade(
42+
{ url: url },
43+
/* Use our copies here */
44+
secWebSocketKey,
45+
secWebSocketProtocol,
46+
secWebSocketExtensions,
47+
context
48+
);
49+
});
50+
4751
}, 1000);
4852

4953
/* You MUST register an abort handler to know if the upgrade was aborted by peer */

0 commit comments

Comments
 (0)