-
Couldn't load subscription status.
- Fork 8
Open
Description
What happened?
Error reported as follows
node:events:489
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED 10.10.10.54:8006
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1570:16)
Emitted 'error' event on ClientRequest instance at:
at TLSSocket.socketErrorListener (node:_http_client:495:9)
at TLSSocket.emit (node:events:511:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '10.10.10.54',
port: 8006
}
In the code below does not handle the req error
cv4pve-api-javascript/src/index.js
Lines 295 to 340 in c58f4cb
| let req = this.#http.request(options, (response) => { | |
| response.setEncoding("utf8"); | |
| let chunks = ""; | |
| response.on("data", (chunk) => { | |
| chunks += chunk; | |
| }); | |
| response.on("end", () => { | |
| let data = null; | |
| if (ref.responseType == ResponseType.JSON) { | |
| data = JSON.parse(chunks); | |
| } else if (ref.responseType == ResponseType.PNG) { | |
| data = "data:image/png;base64," + chunks; | |
| } | |
| const result = new Result( | |
| data, | |
| response.statusCode, | |
| response.statusMessage, | |
| resource, | |
| parameters, | |
| response.method, | |
| ref.responseType | |
| ); | |
| ref.#lastResult = result; | |
| //debug | |
| this.#log(result.toString()); | |
| this.#log(result.response); | |
| resolve(result); | |
| }); | |
| response.on("error", (error) => { | |
| this.#error(error); | |
| reject(error); | |
| }); | |
| }); | |
| if (body != "") { | |
| req.write(body); | |
| } | |
| req.end(); |
We can add an error event listener on the req object to handle potential request errors.
req.on('error', (error) => {
this.#error(error);
reject(error);
});
This way we can use catch to handle errors in our own code
Expected behavior
Please evaluate it.
Relevant log output
No response
Proxmox VE Version
latest
Version (bug)
latest
Version (working)
No response
On what operating system are you experiencing the issue?
Windows, Mac OSX, Linux, Other
Pull Request
- I would like to do a Pull Request
Metadata
Metadata
Assignees
Labels
No labels