Conversation
update `package.json`
```
find src test -name '*.js' |
xargs perl -i -pe 'if (/require\(.[qQ].\)/) { $_ = "import Promise from '\''bluebird'\'';\n"; }'
find src test -name '*.js' |
xargs perl -i -pe 'if (/import [qQ] /) { $_ = "import Promise from '\''bluebird'\'';\n"; }'
```
``` find src test -name '*.js' | xargs perl -i -pe 's/\b[qQ]\(/Promise.resolve(/' ```
```
find src test -name '*.js' |
xargs perl -i -pe 's/q\.(all|defer|reject|delay|try|isFulfilled)\(/Promise.$1(/'
```
Bluebird doesn't have an `allSettled` method, so instead catch the exceptions and use `all`.
turns out that you could call defer.resolve on q defers as an unbound function, whereas that doesn't work with bluebird promises.
dbkr
reviewed
Jul 13, 2017
| // If some of the rules need to be ported then wait for the porting | ||
| // to happen and then fetch the rules again. | ||
| return q.allSettled(needsUpdate).then( function() { | ||
| return q.all(needsUpdate).then( function() { |
Member
There was a problem hiding this comment.
You missed a 'q'. Also surely allSettled != all? Looks like you want reflect (which used to be settle)
Member
Author
There was a problem hiding this comment.
You missed a 'q'.
Oops.
Also surely allSettled != all? Looks like you want reflect (which used to be settle)
the reflect stuff looks confusing to me, so I tried to avoid it, and instead added the catch handler at 1d2d086#diff-beb48c1c7c8677b581a5b4177c817f28R434 to make the promises all succeed.
richvdh
added a commit
that referenced
this pull request
Jul 13, 2017
It turns out that the assertion made in #4565 about `async` functions returning bluebird promises was only correct when babel used an inline version of the `asyncToGenerator` helper; in react-sdk we are using `babel-transform-runtime` which means that we use a separate `babel-runtime/helpers/asyncToGenerator`, which returns a native (or core-js) Promise. This meant that we were still in the situation where some methods returned native Promises, and some bluebird ones, which is exactly the situation I wanted to resolve by switching to bluebird in the first place: in short, unless/until we get rid of all code which assumes Promises have a `done` method etc, we need to make sure that everything returns a bluebird promise. (Aside: there was debate over whether in the long term we should be trying to wean ourselves off bluebird promises by assuming all promises are native. The conclusion was that the complexity hit involved in doing so outweighed any benefit of a potential future migration away from bluebird).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As per matrix-org/matrix-js-sdk#490, we're switching to bluebird.