This message was deleted.
# general
s
This message was deleted.
b
sounds like a race condition where the promises are not awaited so sometimes they are finishing before execution finishes and sometimes they aren't. Are these promises inside of your pulumi program?
i
yes, could be… I am heavily use azure-nextgen
I’ve reduced the footprint of error and have only resource group and 5 stackreferences created in my program fn, still have same issue
Copy code
const stack = await LocalWorkspace.createOrSelectStack({
        stackName: `team/sandbox`,
        projectName,
        program: () =>
          create({
            theme: appConfig.theme,
            appName: deploymentConfig.appName,
            relativeRecordSetName: deploymentConfig.appName,
            baseName: deploymentConfig.baseName,
            emailSupport: '<mailto:support@ssss.com|support@ssss.com>'
          })
      });
will try to remove stack references, or that’s azure-nextgen issuee
ok, my code looks like this now:
Copy code
program: () => {
          const config = new pulumi.Config();

          const location =
            config.get('location') || azurePulumi.Locations.CentralUS;

          const resourceGroup = new resources.ResourceGroup('resourceGroup', {
            resourceGroupName: `${deploymentConfig.appName}-rg`,
            location: location
          });

          return Promise.resolve({
            resourceGroupName: resourceGroup.name
          });
        }
and I keep getting
Copy code
[ExceptionsHandler] The Pulumi runtime detected that 6 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. +42751ms
not using the
azure-nextgen
, keep getting on this
Copy code
program: () => {
    const resourceGroup = new azurePulumi.core.ResourceGroup(
      'resource-group',
      {
        name: `${deploymentConfig.appName}-rg`,
        location: 'centralus'
      }
    );

    return Promise.resolve({
      resourceGroupName: resourceGroup.name,
      fqdn: '<http://hello-world.com>'
    });
  }
Copy code
STACK_TRACE:
Error
    at Object.debuggablePromise (node_modules/@pulumi/pulumi/runtime/debuggable.js:69:75)
    at Object.registerResource (node_modules/@pulumi/pulumi/runtime/resource.js:219:18)
    at new Resource (node_modules/@pulumi/pulumi/resource.js:215:24)
    at new CustomResource (node_modules/@pulumi/pulumi/resource.js:307:9)
    at new ResourceGroup (node_modules/@pulumi/core/resourceGroup.ts:98:9)
    at Object.program [as init] (packages/server/infra-service/src/infra/infra.service.ts:109:43)
    at Stack.<anonymous> (packages/server/infra-service/node_modules/@pulumi/pulumi/runtime/stack.js:86:43)
    at Generator.next (<anonymous>)
    at fulfilled (packages/server/infra-service/node_modules/@pulumi/pulumi/runtime/stack.js:18:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
r
Hi! It looks like your program is returning a promise that is not awaited. Can you try changing it to
Copy code
program: () => {
    const resourceGroup = new azurePulumi.core.ResourceGroup(
      'resource-group',
      {
        name: `${deploymentConfig.appName}-rg`,
        location: 'centralus'
      }
    );
    return {
      resourceGroupName: resourceGroup.name,
      fqdn: '<http://hello-world.com>'
    };
  }
Note that we are just returning an object from the program rather than a promise.
i
@red-match-15116
Copy code
No overload matches this call.
  Overload 1 of 2, '(args: LocalProgramArgs, opts?: LocalWorkspaceOptions | undefined): Promise<Stack>', gave the following error.
    Argument of type '{ stackName: string; projectName: string; program: () => { resourceGroupName: Output<string>; fqdn: string; }; }' is not assignable to parameter of type 'LocalProgramArgs'.
      Object literal may only specify known properties, and 'projectName' does not exist in type 'LocalProgramArgs'.
  Overload 2 of 2, '(args: InlineProgramArgs, opts?: LocalWorkspaceOptions | undefined): Promise<Stack>', gave the following error.
    Type '() => { resourceGroupName: Output<string>; fqdn: string; }' is not assignable to type 'PulumiFn'.
      Type '{ resourceGroupName: Output<string>; fqdn: string; }' is missing the following properties from type 'Promise<void | Record<string, any>>': then, catch, [Symbol.toStringTag], finallyts(2769)
localWorkspace.d.ts(296, 5): The expected type comes from property 'program' which is declared here on type 'InlineProgramArgs'
if you remove Promise.resolve, then types are wrong
Copy code
export declare type PulumiFn = () => Promise<Record<string, any> | void>;
it shouldn’t matter, if the function is promise (async), it should work in both ways 🙂
r
Right, you’re correct. Sorry I missed that your function wasn’t
async
up top. Did you happen to take a look at the example I linked?
i
yes, doesn’t help… I am keeping getting errors
1 run is fine, second fails
r
Since
LocalWorkspace.createOrSelectStack
returns a Promise the entire script needs to be wrapped in an async function. Are you doing this? https://github.com/pulumi/automation-api-examples/blob/main/nodejs/inlineProgram-ts/index.ts#L99 If you still believe something isn’t working as it should feel free to open an issue.
i
createOrSelectStack is called by API call (the service function that you are looking at is the function that will be triggered)
this error is very strange
first run of the code - works perfectly, no issues… all consequenced requests fail
r
Unfortunately, without understanding your full setup it’s difficult to debug. You could try rerunning with
PULUMI_DEBUG_PROMISE_LEAKS=true
to get more verbose logging of error messages. If you feel that there is a bug in pulumi, please open an issue with code to reproduce the issue.
i
I think
PULUMI_DEBUG_PROMISE_LEAKS=true
doesn’t make any changes, due to the way you spawn the process (pulumi)
give me some more time for debug, I will try to understand why “almost” same code works totally different
🙏 1
👍 1
on second run pulumi/runtime looses connection to rpc
any ideas why?
we dig even further and found that .refresh does help for
aws
provider, but not for
azure
, any ideas why? https://github.com/pulumi/pulumi/issues/6457