What is the correct way to catch and handle errors...
# automation-api
p
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
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
@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
Are you running these updates in a parallel? That is currently not supported for node automation api.
p
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
Would you mind opening an issue? https://github.com/pulumi/pulumi/issues/new
r
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
Will do 👍 thanks @lemon-agent-27707 @red-match-15116!
p
Where did you file that issue? I had the same happen and I can add some more context.