Skip to content

1.13.1 and 1.13.2 break ${self:} references. #3627

Description

@daroot

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: aws

causes 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

Activity

  1. pmuens commented on May 16, 2017

    @pmuens
    Contributor

    Thanks for opening @daroot 👍

    The possible fix will be done in #3560

    /cc @eahefnawy

  2. changed the title [-]1.13.1 and 1.13.12 break ${self:} references.[/-] [+]1.13.1 and 1.13.2 break ${self:} references.[/+] on May 25, 2017
  3. sammarks commented on May 31, 2017

    @sammarks
    Contributor

    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.exportThis depends on custom.test, which depends on self, which depends on custom, which depends on custom.exportThis, which depends on custom.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...

  4. pmuens commented on May 31, 2017

    @pmuens
    Contributor

    Thanks for the investigation @sammarks 👍

    Nice catch seeing the cyclic dependency 👀

    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...

    That would be super nifty. I just created #3711 to track the progress on that.

  5. daroot commented on May 31, 2017

    @daroot
    Author

    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?

  6. sammarks commented on May 31, 2017

    @sammarks
    Contributor

    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

  7. pmuens commented on Jun 1, 2017

    @pmuens
    Contributor

    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?

    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

  8. fivepapertigers commented on Jun 9, 2017

    @fivepapertigers

    +1 for this fix. I'm eager to upgrade past 1.12.1, but the cyclic dependency issue is preventing that.

  9. added this to the 1.18 milestone on Jun 29, 2017
  10. modified the milestones: 1.19, 1.18 on Jul 20, 2017
  11. modified the milestones: 1.20, 1.19 on Aug 1, 2017
  12. modified the milestones: 1.20, 1.21 on Aug 16, 2017
  13. modified the milestones: 1.22, 1.21 on Aug 30, 2017
  14. modified the milestones: 1.23, 1.22 on Sep 13, 2017
  15. removed this from the 1.23 milestone on Sep 21, 2017
  16. added this to the 1.25 milestone on Dec 14, 2017
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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions