Skip to content

Resolving unresolved variables inside of ${file(...):func} prints endless "0 of 0 promises have settled" message #7896

Closed

Description

@walery

Sometimes variable that are taken inside of function called from ${file(...js):func} has unresolved variables. See for more details #7895.
It looks like the serverless.variables.populateProperty(...) can resolve strings with variables. As it returns Promise we need to handle it with callback.
Everything works fine except that sls hangs with this message:

 Serverless Information ----------------------------------

  ############################################################################################
    # 2478: 0 of 0 promises have settled
    # 2478: 0 are taking longer than expected:
    # This can result from latent connections but may represent a cyclic variable dependency
    ##########################################################################################

This message didn't stop to appear.

serverless.yml
service: ${self:custom.product}-${self:custom.component}

provider:
  name: aws

custom:
  product: foo
  component: backend

resources:
  - Outputs:
      Foo:
        Value: ${file(foo.js):bar}
foo.js
module.exports.bar = (serverless) => {
    const originalStackName = serverless.providers.aws.naming.getStackName();
    serverless.cli.consoleLog(`\noriginal stackName: ${originalStackName}`);

    return serverless.variables.populateProperty(originalStackName)
        .then(stackName => {
            serverless.cli.consoleLog(`resolved stackName: ${stackName}\n`)

            return new Promise((resolve) => {
                resolve('just dummy... .then(...) version');
            });
        });
};
sls print output
Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command studio
Serverless: Load command dev

original stackName: ${self:custom.product}-${self:custom.component}-dev
resolved stackName: foo-backend-dev

service: foo-backend
provider:
  name: aws
custom:
  product: foo
  component: backend
resources:
  - Outputs:
      Foo:
        Value: just dummy... .then(...) version


 Serverless Information ----------------------------------

  ############################################################################################
    # 2478: 0 of 0 promises have settled
    # 2478: 0 are taking longer than expected:
    # This can result from latent connections but may represent a cyclic variable dependency
    ##########################################################################################


 Serverless Information ----------------------------------

  ############################################################################################
    # 4980: 0 of 0 promises have settled
    # 4980: 0 are taking longer than expected:
    # This can result from latent connections but may represent a cyclic variable dependency
    ##########################################################################################


 Serverless Information ----------------------------------

  ############################################################################################
    # 7482: 0 of 0 promises have settled
    # 7482: 0 are taking longer than expected:
    # This can result from latent connections but may represent a cyclic variable dependency
    ##########################################################################################

^C

Installed version

Framework Core: 1.74.1
Plugin: 3.6.15
SDK: 2.3.1
Components: 2.31.9

Activity

  1. walery commented on Jul 1, 2020

    @walery
    ContributorAuthor

    I've also async/await version of foo.js. But problem remains the same:

    module.exports.bar = (serverless) => {
      return (async () => {
        const originalStackName = serverless.providers.aws.naming.getStackName()
        serverless.cli.consoleLog(`\noriginal stackName: ${originalStackName}`);
    
        const stackName = await serverless.variables.populateProperty(originalStackName);
        serverless.cli.consoleLog(`resolved stackName: ${stackName}\n`)
    
        return new Promise((resolve) => {
          resolve('just dummy... async/await version');
        });
      })();
    };
  2. medikoo commented on Jul 2, 2020

    @medikoo
    Contributor

    @walery Let's keep discussion at #7895

  3. medikoo commented on Jul 2, 2020

    @medikoo
    Contributor

    Duplicate of #7895

  4. walery commented on Jul 2, 2020

    @walery
    ContributorAuthor

    I do not understand why this is duplicate. This ticket aims to issue that after using promises the message 0 of 0 promises have settled didn't disappear.
    The variable resolution is only example where I can demonstrate it.

    I disagree that this is a duplicate.

  5. medikoo commented on Jul 2, 2020

    @medikoo
    Contributor

    I disagree that this is a duplicate.

    it's a side effect of bug at #7895. Fixing #7895 will fix this

  6. medikoo commented on Jul 2, 2020

    @medikoo
    Contributor

    Do you observe same when service is configured with literal string (not variables) ?

  7. walery commented on Jul 2, 2020

    @walery
    ContributorAuthor

    Just tested. Yes same issue with service that is literal string.

    Copy and patsteable version of serverless.yml (in case someone will try it out):

    service: foo-backend
    
    provider:
      name: aws
    
    resources:
      - Outputs:
          Foo:
            Value: ${file(foo.js):bar}
  8. medikoo commented on Jul 2, 2020

    @medikoo
    Contributor

    I didn't notice that you try to rely on serverless.variables.populateProperty

    This is a private API, not intended to be used externally.

    Note that this may change even with a patch release, and relying on this when variables are resolves can indeed produce an unexpected outcome.

  9. medikoo commented on Jul 2, 2020

    @medikoo
    Contributor

    Also I believe the only reason you've decided to rely on it, was to workaround #7895 right? Or do you have any other use case?

  10. walery commented on Jul 2, 2020

    @walery
    ContributorAuthor

    Yes, it was only used as a workaround for #7895

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions