Skip to content

Commit 2079bf8

Browse files
committed
Improve error reporting for failed JVM attach
1 parent f12cc74 commit 2079bf8

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/interceptors/jvm.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,25 @@ const isJavaAvailable = commandExists('java').then(async (isAvailable) => {
2121
]
2222
);
2323

24-
return result.exitCode === 0;
24+
// If Java is present, but it's working, we report it. Hoping that this will hunt done
25+
// some specific incompatibilities that we can better work around/detect.
26+
if (result.exitCode !== 0) {
27+
console.log(result.stdout);
28+
console.log(result.stderr);
29+
throw new Error(`JVM attach not available, exited with ${result.exitCode}`);
30+
} else {
31+
return true;
32+
}
2533
}).catch((e) => {
26-
// This is expected to happen occasionally, e.g. when using Java 8 (which doesn't support
27-
// the VM attachment APIs we need).
28-
console.log("Error checking for JVM targets", e);
34+
// This is expected to happen occasionally, e.g. when using Java 8 (which
35+
// doesn't support the VM attachment APIs we need).
36+
reportError(e);
2937
return false;
3038
});
3139

3240
export class JvmInterceptor implements Interceptor {
3341
readonly id = 'attach-jvm';
34-
readonly version = '1.0.0';
42+
readonly version = '1.0.1';
3543

3644
private interceptedProcesses: {
3745
[pid: string]: number // PID -> proxy port
@@ -113,11 +121,12 @@ export class JvmInterceptor implements Interceptor {
113121
proxyPort.toString(),
114122
this.config.https.certPath
115123
],
116-
{},
117-
true // Inherit IO, so we can see output easily, if any
124+
{}
118125
);
119126

120127
if (interceptionResult.exitCode !== 0) {
128+
console.log(interceptionResult.stdout);
129+
console.log(interceptionResult.stderr);
121130
throw new Error(`Failed to attach to JVM, exit code ${interceptionResult.exitCode}`);
122131
} else {
123132
this.interceptedProcesses[options.targetPid] = proxyPort;

test/integration-test.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ describe('Integration test', function () {
181181
activable('existing-terminal'),
182182
activable('electron', '1.0.1'),
183183
inactivable('android-adb'),
184-
activable('attach-jvm')
184+
activable('attach-jvm', '1.0.1')
185185
]);
186186
});
187187
});

0 commit comments

Comments
 (0)