Respond to unhandled requests

Give an error response back to unhandled requests, this fixes requests
hanging forever when the target does not support the given request.
This commit is contained in:
Hornwitser committed 2020-11-12 04:05:24 +01:00
1 parent 42e680f09d
commit 49eb966315
2 files changed
+22

No files matched your search

+12
View File
@@ -39,6 +39,18 @@ class Link {
if (err.errors) {
console.error(err.errors);
}
// Send back an error response if this was a request.
if (
typeof payload.type === "string"
&& payload.type.endsWith("_request")
&& Number.isInteger(payload.seq)
) {
this.connector.send(
`${payload.type.slice(0, -8)}_response`,
{ seq: payload.seq, error: err.message }
);
}
} else {
this.connector.emit("error", err);
}