mirror of
https://github.com/serverless/serverless.git
synced 2026-02-01 16:07:28 +00:00
fix(Templates): Fix java invoke-bridge build error handling (#7968)
This commit is contained in:
parent
cae28851df
commit
87e7480663
@ -632,15 +632,40 @@ class AwsInvokeLocal {
|
||||
'Building Java bridge, first invocation might take a bit longer.'
|
||||
);
|
||||
|
||||
mvn.stderr.on('data', buf => this.serverless.cli.consoleLog(`mvn - ${buf.toString()}`));
|
||||
|
||||
mvn.on('close', () =>
|
||||
this.callJavaBridge(artifactPath, className, handlerName, input).then(resolve)
|
||||
mvn.stderr.on('data', buf =>
|
||||
this.serverless.cli.consoleLog(`mvn(stderr) - ${buf.toString()}`)
|
||||
);
|
||||
const chunk = [];
|
||||
if (process.env.SLS_DEBUG) {
|
||||
mvn.stdout.on('data', buf => chunk.push(buf));
|
||||
}
|
||||
|
||||
let isRejected = false;
|
||||
mvn.on('error', error => {
|
||||
isRejected = true;
|
||||
reject(error);
|
||||
if (!isRejected) {
|
||||
isRejected = true;
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
|
||||
mvn.on('exit', (code, signal) => {
|
||||
if (code === 0) {
|
||||
this.callJavaBridge(artifactPath, className, handlerName, input).then(resolve);
|
||||
} else if (!isRejected) {
|
||||
if (process.env.SLS_DEBUG) {
|
||||
chunk
|
||||
.map(elem => elem.toString())
|
||||
.join('')
|
||||
.split(/\n/)
|
||||
.forEach(line => {
|
||||
this.serverless.cli.consoleLog(`mvn(stdout) - ${line}`);
|
||||
});
|
||||
}
|
||||
isRejected = true;
|
||||
reject(
|
||||
new Error(`Failed to build the Java bridge. exit code=${code} signal=${signal}`)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
process.nextTick(() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user