Repository navigation
Closed
Description
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
Metadata
Metadata
Assignees
Labels
No labels
Activity
walery commentedon Jul 1, 2020
I've also async/await version of foo.js. But problem remains the same:
medikoo commentedon Jul 2, 2020
@walery Let's keep discussion at #7895
medikoo commentedon Jul 2, 2020
Duplicate of #7895
walery commentedon Jul 2, 2020
I do not understand why this is duplicate. This ticket aims to issue that after using promises the message
0 of 0 promises have settleddidn't disappear.The variable resolution is only example where I can demonstrate it.
I disagree that this is a duplicate.
medikoo commentedon Jul 2, 2020
it's a side effect of bug at #7895. Fixing #7895 will fix this
medikoo commentedon Jul 2, 2020
Do you observe same when
serviceis configured with literal string (not variables) ?walery commentedon Jul 2, 2020
Just tested. Yes same issue with
servicethat is literal string.Copy and patsteable version of
serverless.yml(in case someone will try it out):medikoo commentedon Jul 2, 2020
I didn't notice that you try to rely on
serverless.variables.populatePropertyThis 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.
medikoo commentedon Jul 2, 2020
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?
walery commentedon Jul 2, 2020
Yes, it was only used as a workaround for #7895