Catch JSON parse errors
This commit is contained in:
parent
dd16b3d461
commit
938068703b
|
@ -149,10 +149,15 @@ export default class Client {
|
||||||
this.log("Ignoring line, client is stopped")
|
this.log("Ignoring line, client is stopped")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const req = JSON.parse(line)
|
let req
|
||||||
|
try {
|
||||||
|
req = JSON.parse(line)
|
||||||
|
} catch (err) {
|
||||||
|
this.log("Non-JSON request:", line)
|
||||||
|
return
|
||||||
|
}
|
||||||
if (!req.command || !req.id) {
|
if (!req.command || !req.id) {
|
||||||
console.log("Invalid request, terminating", this.connID)
|
this.log("Invalid request:", line)
|
||||||
await this.stop()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (req.id <= this.maxCommandID) {
|
if (req.id <= this.maxCommandID) {
|
||||||
|
|
Loading…
Reference in New Issue