mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Improve logging from getPortFromStream
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
6615d1bab8
commit
d17319bf85
@ -16,7 +16,10 @@ import { TypedRegEx } from "typed-regex";
|
|||||||
import type { Spawn } from "../child-process/spawn.injectable";
|
import type { Spawn } from "../child-process/spawn.injectable";
|
||||||
import type { Logger } from "../../common/logger";
|
import type { Logger } from "../../common/logger";
|
||||||
|
|
||||||
const startingServeRegex = TypedRegEx("starting to serve on (?<address>.+)", "i");
|
const startingServeMatcher = "starting to serve on (?<address>.+)";
|
||||||
|
const startingServeRegex = Object.assign(TypedRegEx(startingServeMatcher, "i"), {
|
||||||
|
rawMatcher: startingServeMatcher,
|
||||||
|
});
|
||||||
|
|
||||||
export interface KubeAuthProxyDependencies {
|
export interface KubeAuthProxyDependencies {
|
||||||
readonly proxyBinPath: string;
|
readonly proxyBinPath: string;
|
||||||
|
|||||||
@ -9,7 +9,10 @@ import { spawn } from "child_process";
|
|||||||
import * as tcpPortUsed from "tcp-port-used";
|
import * as tcpPortUsed from "tcp-port-used";
|
||||||
import { TypedRegEx } from "typed-regex";
|
import { TypedRegEx } from "typed-regex";
|
||||||
|
|
||||||
const internalPortRegex = TypedRegEx("^forwarding from (?<address>.+) ->", "i");
|
const internalPortMatcher = "^forwarding from (?<address>.+) ->";
|
||||||
|
const internalPortRegex = Object.assign(TypedRegEx(internalPortMatcher, "i"), {
|
||||||
|
rawMatcher: internalPortMatcher,
|
||||||
|
});
|
||||||
|
|
||||||
export interface PortForwardArgs {
|
export interface PortForwardArgs {
|
||||||
clusterId: string;
|
clusterId: string;
|
||||||
|
|||||||
@ -20,6 +20,7 @@ interface GetPortArgs {
|
|||||||
};
|
};
|
||||||
raw?: RegExpExecArray;
|
raw?: RegExpExecArray;
|
||||||
};
|
};
|
||||||
|
rawMatcher: string;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Called when the port is found
|
* Called when the port is found
|
||||||
@ -27,7 +28,7 @@ interface GetPortArgs {
|
|||||||
onFind?: () => void;
|
onFind?: () => void;
|
||||||
/**
|
/**
|
||||||
* Timeout for how long to wait for the port.
|
* Timeout for how long to wait for the port.
|
||||||
* Default: 5s
|
* Default: 15s
|
||||||
*/
|
*/
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
}
|
}
|
||||||
@ -61,7 +62,7 @@ export function getPortFrom(stream: Readable, args: GetPortArgs): Promise<number
|
|||||||
};
|
};
|
||||||
const timeoutID = setTimeout(() => {
|
const timeoutID = setTimeout(() => {
|
||||||
stream.off("data", handler);
|
stream.off("data", handler);
|
||||||
logger.warn(`[getPortFrom]: failed to retrieve port via ${args.lineRegex.toString()}: ${logLines}`);
|
logger.warn(`[getPortFrom]: failed to retrieve port via ${args.lineRegex.rawMatcher}`, logLines);
|
||||||
reject(new Error("failed to retrieve port from stream"));
|
reject(new Error("failed to retrieve port from stream"));
|
||||||
}, args.timeout ?? 15000);
|
}, args.timeout ?? 15000);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user