should fix #4: add a missing withTimeout
parent
9bdeec90f2
commit
1e183247cf
|
|
@ -22,7 +22,7 @@ export async function getStatus(
|
||||||
const socket = connect({ hostname: hostname, port: Number(port) })
|
const socket = connect({ hostname: hostname, port: Number(port) })
|
||||||
const writer = socket.writable.getWriter()
|
const writer = socket.writable.getWriter()
|
||||||
const reader = socket.readable.getReader()
|
const reader = socket.readable.getReader()
|
||||||
await writer.write(new TextEncoder().encode('PING\n'))
|
await withTimeout(monitor.timeout || 10000, writer.write(new TextEncoder().encode('PING\n')))
|
||||||
await withTimeout(monitor.timeout || 10000, reader.read())
|
await withTimeout(monitor.timeout || 10000, reader.read())
|
||||||
await socket.close()
|
await socket.close()
|
||||||
|
|
||||||
|
|
@ -63,9 +63,8 @@ export async function getStatus(
|
||||||
if (monitor.expectedCodes) {
|
if (monitor.expectedCodes) {
|
||||||
if (!monitor.expectedCodes.includes(response.status)) {
|
if (!monitor.expectedCodes.includes(response.status)) {
|
||||||
status.up = false
|
status.up = false
|
||||||
status.err = `Expected codes: ${JSON.stringify(monitor.expectedCodes)}, Got: ${
|
status.err = `Expected codes: ${JSON.stringify(monitor.expectedCodes)}, Got: ${response.status
|
||||||
response.status
|
}`
|
||||||
}`
|
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue