Add log type when error and warn
This commit is contained in:
parent
775b7b287b
commit
71432d7194
@ -8,6 +8,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "ts-node-dev --respawn --transpile-only src/client.ts",
|
"start": "ts-node-dev --respawn --transpile-only src/client.ts",
|
||||||
|
"local": "ts-node-dev --respawn --transpile-only src/client.ts start -p local",
|
||||||
"build": "tsc"
|
"build": "tsc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -98,7 +98,7 @@ function initClient(options: any) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on("connect_error", (e) => {
|
socket.on("connect_error", (e) => {
|
||||||
console.log(
|
console.error(
|
||||||
`${clientLogPrefix} connect error:`,
|
`${clientLogPrefix} connect error:`,
|
||||||
(e && e.message) || "something wrong"
|
(e && e.message) || "something wrong"
|
||||||
);
|
);
|
||||||
@ -108,11 +108,11 @@ function initClient(options: any) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on("disconnect", (reason) => {
|
socket.on("disconnect", (reason) => {
|
||||||
console.log(`${clientLogPrefix} disconnected: ${reason}!`);
|
console.warn(`${clientLogPrefix} disconnected: ${reason}!`);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("disconnect_exit", (reason) => {
|
socket.on("disconnect_exit", (reason) => {
|
||||||
console.log(`${clientLogPrefix} disconnected and exited ${reason}!`);
|
console.warn(`${clientLogPrefix} disconnected and exited ${reason}!`);
|
||||||
socket?.disconnect();
|
socket?.disconnect();
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
@ -133,6 +133,7 @@ function initClient(options: any) {
|
|||||||
tunnelRequest.pipe(localReq);
|
tunnelRequest.pipe(localReq);
|
||||||
|
|
||||||
const onTunnelRequestError = (e: any) => {
|
const onTunnelRequestError = (e: any) => {
|
||||||
|
console.error("tunnel request error: ", e);
|
||||||
tunnelRequest.off("end", onTunnelRequestEnd);
|
tunnelRequest.off("end", onTunnelRequestEnd);
|
||||||
localReq.destroy(e);
|
localReq.destroy(e);
|
||||||
};
|
};
|
||||||
@ -164,7 +165,7 @@ function initClient(options: any) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onLocalError = (error: any) => {
|
const onLocalError = (error: any) => {
|
||||||
console.log(error);
|
console.error("local error:", error);
|
||||||
localReq.off("response", onLocalResponse);
|
localReq.off("response", onLocalResponse);
|
||||||
socket?.emit("request-error", requestId, error && error.message);
|
socket?.emit("request-error", requestId, error && error.message);
|
||||||
tunnelRequest.destroy(error);
|
tunnelRequest.destroy(error);
|
||||||
|
Loading…
Reference in New Issue
Block a user