https://pulumi.com logo
Title
r

rapid-receptionist-28528

03/06/2023, 10:29 AM
Hey, I created a
pulumi
dynamic resource using
typescript
and Implemented all the needed functions (like and update and diff) and then I put an a breakpoint on those functions - but the running application context did not stop on my breakpoints although passing those functions. Any idea ? https://www.pulumi.com/docs/intro/concepts/resources/dynamic-providers/
e

echoing-dinner-19531

03/06/2023, 12:56 PM
Dynamic providers actually run in a sperate process, so debugging them like that is a bit awkward. Even if you could attach to the other process all the code will have gone through closure serialisation so it won't map back to your source code on disk anyway. I think the general fallback here is heavy use of logging calls to debug it.
r

rapid-receptionist-28528

03/23/2023, 12:49 PM
@echoing-dinner-19531 Thanks! How can I let
pulumi
knows of failure in my dynamic resource so
pulumi
could failed the deployment ? I’m asking because I’m in a situation that I had a Error in my implementation and
pulumi
weren’t aware of it , continue to work and didn’t inform me that there is an error and finish the process as it was success.. and I find the the error much later in runtime.
does closing the node process make sense ?
process.exit(0)
e

echoing-dinner-19531

03/23/2023, 1:59 PM
I think if you just throw an error from the dynamic provider method it should get reported back to the engine as an error and stop the deployment
r

rapid-receptionist-28528

03/23/2023, 5:25 PM
@echoing-dinner-19531 I tested that and it does not work.. That is why I’m asking about
process.exit(0)
e

echoing-dinner-19531

03/23/2023, 7:02 PM
That should work, I suspect process.exit will trigger an error somewhere as well. I'll have a poke at this when I get a minute, surprised just throwing an error doesn't work.
r

rapid-receptionist-28528

03/28/2023, 8:24 AM
@echoing-dinner-19531 did you had the chance to check this issue ?
e

echoing-dinner-19531

03/28/2023, 2:49 PM
Sorry not yet, still on my todo list
OK finally got around to testing this quickly. A simple
throw new Error("boom!")
in my dynamic create function seems to work as expected, I'm working on adding a test to our test set to demonstrate this.
r

rapid-receptionist-28528

03/29/2023, 1:20 PM
Thanks @echoing-dinner-19531 if I may summary what you are saying • We found a bug in Pulumi and you recognize it • You are going to add some fix (hopefully soon) • right now, the approach I took with killing the
nodejs
process is the best and maybe the only option to let
pulumi
understand it should failed the deployment.
e

echoing-dinner-19531

03/29/2023, 3:17 PM
No, I don't recognize the bug. I couldn't find any test coverage for this so I've added a test to check this but that test seems to be working without me having to change anything in the SDK. Now might be there's something subtle about one of the other methods (I only tested Create), so if you can give some more details of A) What method your expecting to fail B) How your triggering that failure I can have another look.
r

rapid-receptionist-28528

03/29/2023, 7:44 PM
Thanks! A) method
create
---
async create(inputs: PluginCopyProviderInputs)
B) exactly like you did -
throw new Error("An error occurred")
e

echoing-dinner-19531

03/29/2023, 7:51 PM
Can you raise a bug at https://github.com/pulumi/pulumi/issues with any code snippets, console output, logs from this. As above the simple case for this definitely works, so this not working for you is going to be something more subtle.