header responsive update, fix worker tcp read

This commit is contained in:
lyc8503 committed 2023-10-28 01:38:21 +08:00
1 parent 7e694fd9b7
commit 4817fef547
7 files changed
+60 -40

No files matched your search

+3 -5
View File
@@ -24,14 +24,12 @@ async function getStatus(monitor: MonitorTarget): Promise<{ ping: number; up: bo
const [hostname, port] = monitor.target.split(":")
// Write "PING\n"
const socket = connect({ hostname: hostname, port: Number(port) })
const reader = socket.readable.getReader()
const socket = connect({ hostname: hostname, port: Number(port) })
const writer = socket.writable.getWriter()
await writer.write(new TextEncoder().encode("PING\n"))
await reader.read() // This now works as a workaround for https://github.com/cloudflare/workerd/issues/1305
await socket.close()
// Can't do this: await socket.close()
// TODO: should throw an error here but it doesn't?
// https://github.com/cloudflare/workerd/issues/1305
await socket.closed
console.log(`${monitor.name} connected to ${monitor.target}`)