Skip to content

Commit 2d8b785

Browse files
committed
Fix health socket not getting client messages
Forgot to resume. Went ahead and did the same for the test plugin although it only sends messages and doesn't receive any.
1 parent 7f80d15 commit 2d8b785

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/node/routes/health.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ router.get("/", (req, res) => {
1313
export const wsRouter = WsRouter()
1414

1515
wsRouter.ws("/", async (req) => {
16-
wss.handleUpgrade(req, req.socket, req.head, (ws) => {
17-
ws.on("message", () => {
16+
wss.handleUpgrade(req, req.ws, req.head, (ws) => {
17+
ws.addEventListener("message", () => {
1818
ws.send(
1919
JSON.stringify({
2020
event: "health",
@@ -23,5 +23,6 @@ wsRouter.ws("/", async (req) => {
2323
}),
2424
)
2525
})
26+
req.ws.resume()
2627
})
2728
})

test/test-plugin/src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export const plugin: cs.Plugin = {
2828
wsRouter() {
2929
const wr = cs.WsRouter()
3030
wr.ws("/test-app", (req) => {
31-
cs.wss.handleUpgrade(req, req.socket, req.head, (ws) => {
31+
cs.wss.handleUpgrade(req, req.ws, req.head, (ws) => {
32+
req.ws.resume()
3233
ws.send("hello")
3334
})
3435
})

0 commit comments

Comments
 (0)