You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
All variables should resolve, timeout, or be identified #4687
It is possible to define a project that never resolves variable population.
Description
What went wrong?
I attempted to package a project. SLS loaded and then hung indefinitely.
What did you expect should have happened?
I expected a package to be produced
What was the config you used?
Simple config: serverless.yml:
service: test
provider:
name: aws
custom:
project: ${file(./project.yml)}
project.yml:
foo: baz
bar:
name: ${self:custom.project.foo}
What stacktrace or error message from your provider did you see?
none is given
Additional Data
I've instrumented the code and produced the following list of unresolved variable resolutions:
unsettled promises:
file(./project.yml) waited on by:
${file(./project.yml)}
${file(./project.yml)}
self:custom.project.foo waited on by:
${self:custom.project.foo}
The problem is that resolving ${file(./project.yml)} involves, prior to replacing the custom.project attribute on the service object, attempting to resolve ${self:custom.project.foo} which then circularly attempts to resolve ${file(./project.yml)} again, resulting in a deadlock since ${file(./project.yml)} now cannot resolve until ${file(./project.yml)} is resolved.
It could have been any asynchronously resolving variable that referred to itself prior to being replaced in the origin object.
Serverless Framework Version you're using: 1.25.0 / master
changed the title [-]All variables should resolve or be identified as failing to resolve[/-][+]All variables should resolve, timeout, or be identified[/+]on Jan 27, 2018
Serverless Error ---------------------------------------
Inaccessible host: `cloudformation.'. This service may not be available in the `${deep:1.region}' region.
@erikerikson Your welcome. One thing I wasn't able to determine is that by allowing root recursion to continue, did I introduce infinite recursion if there is a env var loop? If I did, then I would suggest instead of a boolean for root, rename root to depth and make it an integer for max depth. e.g. allow recursion say 10 depth and then error out if not resolved.
It is possible to "infinitely" recurse if someone introduced an explicit ungroundable cycle in their references. The behavior of the framework, prior to any of these changes, was to recurse until the stack became too deep and was rejected by the VM. This results in a crash and that seemed appropriate enough behavior. I think now it will deadlock and report the offending (pending) variables. I'd certainly suggest that 10 would be far too low a number given the number of generations that some of these evaluations go through (particularly on complex services).
That said some sort of safety mechanism that would give users a more legible error or statement of the conditions would be helpful. I suppose it would be best to come up with a service that reproduces the case before fixing the matter however.
I've noticed that if you mistakenly have a variable reference itself it gets stuck in what appears to be an infinite loop. I've waited many minutes, and the deploy process provides no feedback nor does it error out.
An example I mistakenly did due to a bad cut and paste in my serverless.yml:
Interesting @aposto. I would expect that to be the case and there isn't logic to detect it. I'd guess that's worthy of an issue if you're willing to open one up?
Under the covers it will be waiting on its own promise, an obvious deadlock. Sorry about the bug.
Activity
[-]Never resolving variables[/-][+]All variables should resolve or be identified as failing to resolve[/+][-]All variables should resolve or be identified as failing to resolve[/-][+]All variables should resolve, timeout, or be identified[/+]Merge pull request #4713 from erikerikson/fix-4687-cyclic-variable-de…
bsdkurt commentedon Mar 4, 2018
Can this be reopened? I found case where the recursion does not go far enough. The following serverless.yml fails:
with the following error
Continue recursion for serverless#4687
erikerikson commentedon Mar 4, 2018
@bsdkurt Thanks for reporting this and offering a change too!
bsdkurt commentedon Mar 4, 2018
@erikerikson Your welcome. One thing I wasn't able to determine is that by allowing root recursion to continue, did I introduce infinite recursion if there is a env var loop? If I did, then I would suggest instead of a boolean for root, rename root to depth and make it an integer for max depth. e.g. allow recursion say 10 depth and then error out if not resolved.
erikerikson commentedon Mar 4, 2018
It is possible to "infinitely" recurse if someone introduced an explicit ungroundable cycle in their references. The behavior of the framework, prior to any of these changes, was to recurse until the stack became too deep and was rejected by the VM. This results in a crash and that seemed appropriate enough behavior. I think now it will deadlock and report the offending (pending) variables. I'd certainly suggest that 10 would be far too low a number given the number of generations that some of these evaluations go through (particularly on complex services).
That said some sort of safety mechanism that would give users a more legible error or statement of the conditions would be helpful. I suppose it would be best to come up with a service that reproduces the case before fixing the matter however.
HyperBrain commentedon Mar 5, 2018
@erikerikson @bsdkurt Please keep me updated on the discussion and the state of any additional PRs. I'll take care of merging then.
erikerikson commentedon Mar 5, 2018
I've offered a test on #4800. I think after it is included, #4800 should be GTM.
Merge pull request #4800 from bsdkurt/master
apsoto commentedon Jun 2, 2020
I've noticed that if you mistakenly have a variable reference itself it gets stuck in what appears to be an infinite loop. I've waited many minutes, and the deploy process provides no feedback nor does it error out.
An example I mistakenly did due to a bad cut and paste in my serverless.yml:
erikerikson commentedon Jun 2, 2020
Interesting @aposto. I would expect that to be the case and there isn't logic to detect it. I'd guess that's worthy of an issue if you're willing to open one up?
Under the covers it will be waiting on its own promise, an obvious deadlock. Sorry about the bug.