Skip to content

Commit

Permalink
Fix #9065 for previews (#9272)
Browse files Browse the repository at this point in the history
* Fix #9065 for previews

Same fix as in #9097 but for the preview command.

* Add to CHANGELOG
  • Loading branch information
Frassle committed Mar 23, 2022
1 parent d7393a3 commit 5b90b64
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG_PENDING.md
Expand Up @@ -18,14 +18,17 @@
- [cli/plugins] - Improved error message for missing plugins.
[#5208](https://github.com/pulumi/pulumi/pull/5208)

- [sdk/nodejs] - Take engines property into account when engine-strict appear in npmrc file
- [sdk/nodejs] - Take engines property into account when engine-strict appear in npmrc file
[#9249](https://github.com/pulumi/pulumi/pull/9249)

### Bug Fixes

- [sdk/nodejs] - Fix uncaught error "ENOENT: no such file or directory" when an error occurs during the stack up.
[#9065](https://github.com/pulumi/pulumi/issues/9065)

- [sdk/nodejs] - Fix uncaught error "ENOENT: no such file or directory" when an error occurs during the stack preview.
[#9272](https://github.com/pulumi/pulumi/issues/9272)

- [sdk/go] - Fix a panic in `pulumi.All` when using pointer inputs.
[#9197](https://github.com/pulumi/pulumi/issues/9197)

Expand Down
17 changes: 7 additions & 10 deletions sdk/nodejs/automation/stack.ts
Expand Up @@ -231,10 +231,9 @@ Event: ${line}\n${e.toString()}`);
});
}

const upPromise = this.runPulumiCmd(args, opts?.onOutput);
let upResult: CommandResult;
try {
upResult = await upPromise;
upResult = await this.runPulumiCmd(args, opts?.onOutput);
} catch (e) {
didError = true;
throw e;
Expand Down Expand Up @@ -335,7 +334,7 @@ Event: ${line}\n${e.toString()}`);
const logFile = createLogFile("preview");
args.push("--event-log", logFile);
let summaryEvent: SummaryEvent | undefined;
const rlPromise = this.readLines(logFile, (event) => {
const logPromise = this.readLines(logFile, (event) => {
if (event.summaryEvent) {
summaryEvent = event.summaryEvent;
}
Expand All @@ -344,27 +343,25 @@ Event: ${line}\n${e.toString()}`);
onEvent(event);
}
});
const prePromise = this.runPulumiCmd(args, opts?.onOutput);

let preResult: CommandResult;
let rlResult: ReadlineResult | undefined;
let previewResult: CommandResult;
try {
[preResult, rlResult] = await Promise.all([prePromise, rlPromise]);
previewResult = await this.runPulumiCmd(args, opts?.onOutput);
} catch (e) {
didError = true;
throw e;
} finally {
onExit(didError);
await cleanUp(logFile, rlResult);
await cleanUp(logFile, await logPromise);
}

if (!summaryEvent) {
log.warn("Failed to parse summary event, but preview succeeded. PreviewResult `changeSummary` will be empty.");
}

return {
stdout: preResult.stdout,
stderr: preResult.stderr,
stdout: previewResult.stdout,
stderr: previewResult.stderr,
changeSummary: summaryEvent?.resourceChanges || {},
};
}
Expand Down

0 comments on commit 5b90b64

Please sign in to comment.