Hey, I created a `pulumi` dynamic resource using ...
# general
r
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
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
@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 ?
Copy code
process.exit(0)
e
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
@echoing-dinner-19531 I tested that and it does not work.. That is why I’m asking about
process.exit(0)
e
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
@echoing-dinner-19531 did you had the chance to check this issue ?
e
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
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
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
Thanks! A) method
create
---
Copy code
async create(inputs: PluginCopyProviderInputs)
B) exactly like you did -
throw new Error("An error occurred")
e
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.