Skip to content

Commit c2a5579

Browse files
authored
fix: Cannot read properties of undefined (reading 'startsWith') (#968)
Signed-off-by: Yan Zhang <[email protected]>
1 parent b33290b commit c2a5579

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/daemon/clientLog/logWatcher.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ export class ClientLogWatcher {
2121
if (logs) {
2222
const info: any = {};
2323

24-
const jdkLog = logs.find(log => log.message.startsWith("Use the JDK from"));
24+
const jdkLog = logs.find(log => log.message?.startsWith("Use the JDK from"));
2525
info.defaultProjectJdk = jdkLog?.message.replace("Use the JDK from '", "").replace("' as the initial default project JDK.", "");
2626

27-
const startupLog = logs.find(log => log.message.startsWith("Starting Java server with:") && log.message.endsWith("jdt_ws") /* limit to standard server */);
27+
const startupLog = logs.find(log => log.message?.startsWith("Starting Java server with:") && log.message.endsWith("jdt_ws") /* limit to standard server */);
2828
if (startupLog) {
2929
info.xmx = startupLog.message.match(/-Xmx[0-9kmgKMG]+/g)?.[0];
3030
info.xms = startupLog.message.match(/-Xms[0-9kmgKMG]+/g)?.[0];
@@ -36,11 +36,11 @@ export class ClientLogWatcher {
3636
info.error = errorLog ? "true" : undefined;
3737

3838
const missingJar = "Error opening zip file or JAR manifest missing"; // lombok especially
39-
if (logs.find(log => log.message.startsWith(missingJar))) {
39+
if (logs.find(log => log.message?.startsWith(missingJar))) {
4040
info.error = missingJar;
4141
}
4242

43-
const crashLog = logs.find(log => log.message.startsWith("The Language Support for Java server crashed and will restart."));
43+
const crashLog = logs.find(log => log.message?.startsWith("The Language Support for Java server crashed and will restart."));
4444
info.crash = crashLog ? "true" : undefined;
4545

4646
sendInfo("", {

0 commit comments

Comments
 (0)