Hi,. What I am doing wrong here? ```pulumi.runti...
# typescript
b
Hi,. What I am doing wrong here?
Copy code
pulumi.runtime.registerResourceTransform((args) => {
    if (args.props['tags']) {
        args.props['tags'] = { ...args.props['tags'], test: 'test' }
    }
    return { props: args.props, opts: args.opts }
})
Copy code
The Pulumi runtime detected that 4640 promises were still active
    at the time that the process exited. There are a few ways that this can occur:
      * Not using `await` or `.then` on a Promise returned from a Pulumi API
      * Introducing a cyclic dependency between two Pulumi Resources
      * A bug in the Pulumi Runtime
    Leaving promises active is probably not what you want. If you are unsure about
    why you are seeing this message, re-run your program with the `PULUMI_DEBUG_PROMISE_LEAKS`
    environment variable. The Pulumi runtime will then print out additional
    debug information about the leaked promises.
l
Your project is finishing early (e.g. due to an exception), you're forcefully quitting, or similar. You need to debug this. I recommend creating a new stack (so as not to affect any already-deployed resources), determining the minimal action required to reproduce (does preview do it? or do you need to up?), and then comment out code until the problem goes away.
b
htanks, sorry for the lack of context, in general the project was working well until I added that transform
m
I can't make it work either. I have a very basic stack to make this work, so no error for me but no changes
l
Isn't the function
registerStackTransformation
? I can't see
registerStackTransform
in the docs.
m
Yes it's registerStackTransformation, registerStackTransform exists but is obsolete. But it does not work either
l
Ah, plus it's the resource function anyway. And that's correct.
What happens if you set tags on a type that doesn't allow tags? That is, if the input is wrong? I've checked the code I use for this, and it has a list of types that it allows itself to work with -- it's based on Joe Duffy's blog post from 4 or 5 years ago.
m
I don't know but I tried with 2 resources (resource group and storage account) that accepts tags and I did not get any error but no tag either. It's like it's not running the stack transformation at all ...
l
Is it leaking promises?
m
I don't know what is it doing. The code is very simple (I just wanted to test Transforms) but does not seem to work :
Copy code
const resourceGroup = new azureNative.resources.ResourceGroup("rg-transforms", {
    location: "WestUS",
});

// Apply a tag with the stack name to all resources
pulumi.runtime.registerStackTransformation((args) => {
    args.props['tags'] = { ...args.props['tags'], test: 'test' }
    return { props: args.props, opts: args.opts };
});
l
Is it the first thing you do? Before creating any resource instances?
I note that in my implementation, I use:
Copy code
if (isTaggable(...) {
  args.props.tags = /* stuff */;
  return { props: args.props, opts: args.opts ];
}
return undefined;
The two substantive differences are that I'm mutating
args
itself (probably not important), and I'm returning
undefined
for resources that don't support the tags prop.
m
Yes that's all I have in my stack. no other resources so it should not be a problem not to check if the resource is taggable or not
l
Well, remember the stack is a resource. You may have to return undefined for that.
m
I did not think about this one
Still no luck with that :
Copy code
pulumi.runtime.registerStackTransformation((args) => {
    if (args.type == "azure-native:resources:ResourceGroup") {
        args.props.tags = { test: 'test' }
        return { props: args.props, opts: args.opts };
    }
    return undefined;
});