https://pulumi.com logo
Title
p

plain-dawn-65221

09/17/2021, 11:41 PM
What is the correct way to catch and handle errors with the Pulumi Automation API? Here's a very small sample where we do not set the
new ec2.Instance()
arguments properly Errors like this result in a large number of
UnhandledPromiseRejectionWarnings
, fills up our logging, and if running in an unattended loop seem to crash the Pulumi runtime If someone is able to advise on the best approach for handling
stack.up()
errors, we'd appreciate it!
l

lemon-agent-27707

09/20/2021, 2:23 PM
Can you share your what versions of the
@pulumi/pulumi
and related packages you're using (maybe share package.json)
And just to clarify, is the problem the large number of log messages? Or is your error handling logic not running at all?
p

plain-dawn-65221

09/20/2021, 7:53 PM
@lemon-agent-27707 sure thing 👍 The
package.json
for the small sample above is attached. Using: •
@pulumi/aws
4.20.0
@pulumi/pulumi
3.12.0
1
In our use case, we have an application that is running a loop to "reconcile" our Pulumi stacks in AWS against incoming change requests We have a loop running in that application that calls
stack.up()
for each stack, which either applies the changes, or does nothing (if no change requests came in) It seems like what we are observing is that if a change request comes in for one of the stacks that causes a
stack.up()
error on that one stack, there are cascading effects on the other stacks — our best guess is that the Pulumi runtime is somehow affected The other "healthy" stacks will run
stack.up()
and output a single generic error at the end that says "one or more errors occurred" If we delete the single stack that we know has an error, then
stack.up()
returns to functioning properly on the other stacks
TL;DR it seems like (our best guess) errors from
stack.up()
are causing wide-ranging problems in our use case, and we're wondering what the best way to catch and handle
stack.up()
errors are
I'll try to adapt the small example above ^ to demonstrate the problem in a loop
l

lemon-agent-27707

09/20/2021, 8:21 PM
Are you running these updates in a parallel? That is currently not supported for node automation api.
p

plain-dawn-65221

09/21/2021, 2:01 PM
We aren't, the
stack.up()
operations are sequential ("serial")
Apologies, didn't get sample complete yesterday, will hopefully have small sample to demo problem soon
I guess before I get to that point though, one question: I've added
try
catch
in as many places as I could think to in the
main.js
file above ^ The error output still shows
UnhandledPromiseRejectionWarnings
To phrase my original question better: • What promise isn't being handled? Is it in the
main.js
file somewhere or somewhere in Pulumi SDK?
l

lemon-agent-27707

09/22/2021, 2:18 AM
Would you mind opening an issue? https://github.com/pulumi/pulumi/issues/new
r

red-match-15116

09/22/2021, 2:47 AM
What promise isn’t being handled? Is it in the 
main.js
 file somewhere or somewhere in Pulumi SDK?
Your code sample appears correct, this seems like an issue within the Pulumi SDK
p

plain-dawn-65221

09/22/2021, 3:37 AM
Will do 👍 thanks @lemon-agent-27707 @red-match-15116!
p

proud-pizza-80589

10/12/2021, 2:49 PM
Where did you file that issue? I had the same happen and I can add some more context.