Repository navigation
Conversation
|
|
||
| functions() { | ||
| return new Promise((resolve) => { | ||
| return new BbPromise((resolve) => { |
There was a problem hiding this comment.
I suggest to use BbPromisy.try() instead of the new BbPromise anti-pattern:
return BbPromise.try(() => {
this.deployedFunctions = this.deployedFunctions + 1;
})This will also catch any synchronous throws and rejects your promise accordingly.
There was a problem hiding this comment.
Thanks for looking into this @arabold 👍 really helpful tips!
| _.deepMapValues(this.service, (property, propertyPath) => { | ||
| if (typeof property === 'string') { | ||
| const populateSingleProperty = new Promise((resolve) => this | ||
| const populateSingleProperty = new BbPromise((resolve) => this |
There was a problem hiding this comment.
Let me try to decrypt this:
const populateSingleProperty = this.populateProperty(property, true)
.then(newProperty => _.set(this.service, propertyPath, newProperty)
.return();This should be equal and seems more straight forward to me. new BbPromise() should really be avoided and isn't even necessary here. If any function doesn't return a BbPromise but a plain native Promise, it's easiest to wrap it using BbPromise.resolve(myNativePromiseFunc()).then(...).
There was a problem hiding this comment.
I also think that the original code can cause unhandled rejections as there's no reject callback defined. If there's a rejection in populateProperty() then this little call would never finish as resolve() is never triggered IMO. I definitely suggest to rework the code into something similar to what I suggested above.
There was a problem hiding this comment.
Awesome! Thanks for the suggestion.
The current code in master causes a regression in the resolving step for the custom variable syntax. Having this (🔝 ) in place should prevent this and makes this more robust (it was uncovered "by accident")! 👍
f27661d to
675e371
Compare
675e371 to
5c08d60
Compare
5c08d60 to
617ddee
Compare
617ddee to
0e4b31a
Compare
What did you implement:
This is a follow-up PR on #3554. The main purpose was to shrinkwrap and switch the whole codebase to Bluebird promises.
I think I uncovered a problem in the variable system. Seems like this code produces an infinite loop when using Bluebird.
The test which introduces the infinite loop is the one which tests for the usage of the custom variable syntax (see here).
You can see this by checking out this PR and adding a simple
console.log()here (inside theif) and running the tests after that./cc @eahefnawy @brianneisler