[automation/nodejs] - Only log, don't error on unparsed events (#7162)

This commit is contained in:
Komal 2021-05-28 09:15:45 -07:00 committed by GitHub
parent e1576d13b3
commit 9c1964e622
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View file

@ -1,7 +1,5 @@
### Improvements
- [codegen] - Encrypt input args for secret properties.
[#7128](https://github.com/pulumi/pulumi/pull/7128)
@ -10,3 +8,6 @@
- [cli] - Send plugin install output to stderr, so that it doesn't
clutter up --json, automation API scenarios, and so on.
[#7115](https://github.com/pulumi/pulumi/pull/7115)
- [auto/nodejs] - Emit warning instead of breaking on parsing JSON events for automation API.
[#7162](https://github.com/pulumi/pulumi/pull/7162)

View file

@ -126,11 +126,14 @@ export class Stack {
let event: EngineEvent;
try {
event = JSON.parse(line);
callback(event);
} catch (e) {
log.error(`failed to parse engine event\nevent: ${line}\n${e.toString()}`);
throw e;
log.warn(`Failed to parse engine event
If you're seeing this warning, please comment on https://github.com/pulumi/pulumi/issues/6768 with the event and any
details about your environment.
Event: ${line}\n${e.toString()}`);
}
callback(event);
});
return {
@ -351,13 +354,13 @@ export class Stack {
}
if (!summaryEvent) {
throw new Error("No summary of changes.");
log.warn("Failed to parse summary event, but preview succeeded. PreviewResult `changeSummary` will be empty.");
}
return {
stdout: preResult.stdout,
stderr: preResult.stderr,
changeSummary: summaryEvent.resourceChanges,
changeSummary: summaryEvent?.resourceChanges || {},
};
}
/**
@ -675,7 +678,7 @@ export type OpType = "same"
* A map of operation types and their corresponding counts.
*/
export type OpMap = {
[key in OpType]: number;
[key in OpType]?: number;
};
/**