New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove bluebird #3650
remove bluebird #3650
Conversation
Wait for #3634 |
d648c2c
to
142ab3a
Compare
todo one of:
|
lib/client.js
Outdated
}); | ||
} catch (e) { | ||
return Bluebird.reject(e); | ||
return Promise.reject(new Error('Unable to acquire a connection')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for an explicit Promise.reject
here. Since this is an async
function, all you have to do is throw the error and the caller will see the promise this function returns become rejected.
Similar for the promise chain below. Better to await etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
1ec999f
to
6f49b74
Compare
Howdy! Just curious: what's the intended scope of this PR?
The reason I'm asking: this seems like it could potentially touch a lot of code, which will make it challenging to code review. So, perhaps the overall effort can be split into several smaller PRs? |
I agree with the idea of smaller PRs being better and this is something we should in general strive for; however, at this point it's likely that PR split is going to take non-trivial effort; if that is the case, I'd rather review a larger PR than lose part of refactoring due to simple revert. |
That said, since PR is pretty large already, it might make sense to wrap up what was already changed into final state, review, merge and continue in a separate PR, rather than keep expanding this one. |
In some places conversion from promise chain to async/await done because of node 8 support and .finally usage |
ba17813
to
0a05034
Compare
In terms of the "smaller PR" discussion: we don't necessarily need to revert any changes. Instead, we could use this branch as a basis for generating smaller incremental patches: For example:
There might be more steps as well, of course. The main concept: you don't need to manually recreate the changes. Instead, you can use this branch as the basis for generating multiple patch sets. This will then make it significantly easier to review and merge the code. I can assist you with this if you'd like to give it a try. |
Side note: I also see why this is such a challenging PR. I just replaced a Bluebird Promise in 1 line of code, and suddenly 15 seemingly-unrelated sections of the code exploded. 🙀 It turns out that those sections of the code all relied upon the |
test/utils.js
Outdated
@@ -0,0 +1,8 @@ | |||
const assert = require('assert'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be chai for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code removed
t.ok( | ||
e.message.indexOf('i-refuse-to-exist') > 0, | ||
e.message.includes('i-refuse-to-exist'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice :)
Preferably we keep Node 8 support until Node 14 lands. |
test/utils.js
Outdated
const assert = require('assert'); | ||
|
||
const expectError = (promise) => | ||
promise.then(() => assert.fail("Shouldn't have gotten here."), (e) => e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might also consider using the chai-as-promised
plugin:
https://www.chaijs.com/plugins/chai-as-promised/
This encapsulates the pattern of "failing when an exception didn't occur".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
}; | ||
} | ||
); | ||
availablePromiseMethods().forEach(function(method) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The list produced by availablePromiseMethods()
is significantly shorter than the list that it's replacing. Was this intentional? (Granted: I'm assuming that many of the methods in the original list were Bluebird-specific)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this methods are from bluebird
|
||
then(onResolve, onReject) { | ||
return this._promise.then(onResolve, onReject); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: this is probably related to the "availablePromiseMethods()
list is significantly shorter than the list that it's replacing" concern that I mentioned elsewhere. The availablePromiseMethods()
method is currently omitting "then"
.
In other words: if the list produced by availablePromiseMethods()
included "then"
, then you probably could just rely upon meta-programming to generate this method automatically.
(On the flipside: given that the list of Promise methods only contains 2-3 elements now, it might no longer be worth leveraging meta-programming for this.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not work, because interface has non-trivial then (but this can be replaced to some internal method too, but this too complex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
helper which generates array of promise methods helps with optional .finally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right -- we're saying the same thing. Basically: you can't use meta-programming for this specific case. However, given that there are only a handful of cases now, it might be worth discarding the meta-programming in favor of something more explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done: 9ef6369
Sorry for delay, didn't quickly realize your proposed solution
@@ -0,0 +1,5 @@ | |||
function availablePromiseMethods() { | |||
return Promise.prototype.finally ? ['catch', 'finally'] : ['catch']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... based upon the Knex documentation, it looks like the .finally(..)
method is intentionally being made available to older versions of Node. (Specifically: release notes for version 0.20.2
). So, perhaps we should eliminate the conditional logic here and just always provide the .finally(..)
method? (Of course, the meta-programming might interfere with this. So... perhaps we should avoid meta-programming for generating these methods?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.20.2 is about typings only, as I can see
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These release notes for 0.20.2
on http://knexjs.org/ mention this:
Fix regression in older version of node when Promise#finally was not available #3507
(Perhaps this line was omitted from another copy of the release notes?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked #3507 pr
I can't change lib/ code without changing test/, because tests depends on .finally, which is incompatible with node 8 |
this.driver.connect(this.connectionSettings, (err, connection) => { | ||
if (err) return rejecter(err); | ||
Bluebird.promisifyAll(connection); | ||
connection.executeAsync = promisify(connection.execute); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here attention needed: check all file and notice, what from connection only execute (with suffix async) is used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: I discovered earlier today that lib/dialects/oracle
is actually partially-dead code. It is not used anywhere except as a parent class for lib/dialects/oracledb
.
So, you might want to double-check that this method is even used by lib/dialects/oracledb
. If not, then it might be easiest to just remove the entire method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's easier to drop support for https://www.npmjs.com/package/oracle entirely, but this is not logical part of this merge request
function(value, index) { | ||
const OutBindsOffset = index * modifiedRowsCount; | ||
updatedOutBinds.push(outBinds[i + OutBindsOffset]); | ||
return connection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
github is bad at diffing with spaces: here only Bluebird.resolve removed
@@ -1148,39 +1147,37 @@ module.exports = function(knex) { | |||
if (/redshift/i.test(knex.client.driverName)) { | |||
return; | |||
} | |||
this.timeout(10000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previously this was timeout on bluebird chain
@maximelkin + @kibertoad : I've been reviewing the code, but the huge number of changes makes it difficult to be very confident about the code review (fun fact: it's actually 63 pages worth of changes). Would it be possible to split this into at least 2 separate PRs? In particular:
(Ideally, I'd really like to see each of these split into 2-3 separate PRs as well. But, splitting things this way will at least allow us to be a lot more confident in the code reviews). In terms of strategy, you can do the following:
(This will replay your commits against
At this point, it should be possible to run the tests against the older code. Once we're confident that the tests are good, we can merge them. Afterwards, we can apply the patch to create a new PR that contains the other half of the changes:
Again: I apologize for asking you to do this, but it would really allow everybody to be a lot more confident about the changes that were implemented. |
Closing #1588