Repository navigation
Description
This is a Bug Report
Description
For bug reports:
- What went wrong?
running sls package against this serverless.yml file:
service: test
custom:
test: ${self:}
exportThis: ${self:custom.test.service}
provider: awscauses an infinitely recursive loop that crashes serverless.
- What did you expect should have happened?
should have produced a package for deployment.
- What stacktrace or error message from your provider did you see?
<--- Last few GCs --->
[20894:0x104800000] 770076 ms: Mark-sweep 2790.2 (3047.1) -> 2790.1 (2985.1) MB, 2995.9 / 0.0 ms last resort
[20894:0x104800000] 773017 ms: Mark-sweep 2790.1 (2985.1) -> 2790.1 (2960.1) MB, 2940.1 / 0.0 ms last resort
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x47a495266a1 <JS Object>
1: _then [/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:~219] [pc=0x25add9e48667](this=0xeef459b2451 <a Promise with map 0x3014c5dce181>,didFulfill=0x718d9cf5c11 <JS Function gotAccum (SharedFuncti
onInfo 0x2a30dadc3eb9)>,didReject=0x24687c502311 <undefined>,_=0x24687c502311 <undefined>,receiver=0x8181f660071 <an Object with map 0x28376fe425d1>,internalDat...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [/usr/local/bin/node]
2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
3: v8::Utils::ReportOOMFailure(char const*, bool) [/usr/local/bin/node]
4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
5: v8::internal::Factory::NewUninitializedFixedArray(int) [/usr/local/bin/node]
6: v8::internal::(anonymous namespace)::ElementsAccessorBase<v8::internal::(anonymous namespace)::FastHoleyObjectElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits<(v8::internal::ElementsKind)3> >::ConvertElementsW
ithCapacity(v8::internal::Handle<v8::internal::JSObject>, v8::internal::Handle<v8::internal::FixedArrayBase>, v8::internal::ElementsKind, unsigned int, unsigned int, unsigned int, int) [/usr/local/bin/node]
7: v8::internal::(anonymous namespace)::ElementsAccessorBase<v8::internal::(anonymous namespace)::FastHoleyObjectElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits<(v8::internal::ElementsKind)3> >::GrowCapacityAndC
onvertImpl(v8::internal::Handle<v8::internal::JSObject>, unsigned int) [/usr/local/bin/node]
8: v8::internal::(anonymous namespace)::FastElementsAccessor<v8::internal::(anonymous namespace)::FastHoleyObjectElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits<(v8::internal::ElementsKind)3> >::AddImpl(v8::inte
rnal::Handle<v8::internal::JSObject>, unsigned int, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, unsigned int) [/usr/local/bin/node]
9: v8::internal::JSObject::AddDataElement(v8::internal::Handle<v8::internal::JSObject>, unsigned int, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyAttributes, v8::internal::Object::ShouldThrow) [/usr/local/bin/node]
10: v8::internal::Runtime::SetObjectProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::LanguageMode) [/usr/loc
al/bin/node]
11: v8::internal::Runtime_SetProperty(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
12: 0x25add98043a7
abort
Additional Data
- Serverless Framework Version you're using: 1.13.1 and 1.13.2; 1.13.0 does not exhibit the problem.
- Operating System:
; sw_vers
ProductName: Mac OS X
ProductVersion: 10.12.4
BuildVersion: 16E195
Reacted by Nicki Hoffman, Dan Coates, Nick Geller and dev101
Activity
pmuens commentedon May 16, 2017
Thanks for opening @daroot 👍
The possible fix will be done in #3560
/cc @eahefnawy
[-]1.13.1 and 1.13.12 break ${self:} references.[/-][+]1.13.1 and 1.13.2 break ${self:} references.[/+]sammarks commentedon May 31, 2017
I'm not sure #3560 is going to fix this. Since it appears the variable loading is now entirely promise-based, you'll have to watch out for cyclic dependencies. In the example above,
custom.exportThisdepends oncustom.test, which depends onself, which depends oncustom, which depends oncustom.exportThis, which depends oncustom.test...I opened another PR to expand upon #3560 (since I appear to have fixed the tests in my research, so might as well supply the PR), but I think this is just a fundamental change in how the configuration is managed. Developers will have to be wary in the future about cyclic dependencies in their configs.
Would be nice if we could detect the cyclic dependencies and show a warning to the user, but I'll save that for another PR...
pmuens commentedon May 31, 2017
Thanks for the investigation @sammarks 👍
Nice catch seeing the cyclic dependency 👀
That would be super nifty. I just created #3711 to track the progress on that.
daroot commentedon May 31, 2017
This style of ${self:} dependency seems to be a common recommendation for cross-service variable dependencies. It was explicitly added in #3207, and is quite heavily used in the hello-retail project.
I've got a project that copied this pattern for referencing variables across services from hello-retail, and it works fine under 1.12.x, but breaks under 1.13.x; The above serverless.yml is the minimal reproduction, but the general use case is that without the ability to resolve a seemingly recursive ${self:} and chaining all references through it, using ${file()} becomes far less useful, as including another serverless.yml with any ${self:whatever} usage at all is going to break.
If the new promise-based variable system can't support this sort of ${self:}, what's the recommendation for sharing sets of variables, including possibly mutually dependent ones, between services?
sammarks commentedon May 31, 2017
I think the rule of thumb is if you're going to use the
${self:}references inside an imported configuration file, you cannot reference variables inside the file itself - you have to reference variables in the root configuration only.Since that's not optimal in some cases, @pmuens opened an issue here to detect those: #3711
pmuens commentedon Jun 1, 2017
Yes, there seems to be something off here. We need to investigate further on this one 🤔
@sammarks advice above sounds like a good rule of thumb for now 🔝
/cc @eahefnawy
fivepapertigers commentedon Jun 9, 2017
+1 for this fix. I'm eager to upgrade past 1.12.1, but the cyclic dependency issue is preventing that.