Skip to content
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

Adapt to change in superagent lib #68

Merged
merged 7 commits into from
Sep 14, 2017

Conversation

bmancini42
Copy link
Contributor

To address issue #67

@bmancini42
Copy link
Contributor Author

The functionality of the function in question seems to be the same, just a name change as far as I can tell.

@bmancini42
Copy link
Contributor Author

Actually, the checks failing seem to indicate this does not work

@DevSide
Copy link
Contributor

DevSide commented Sep 6, 2017

Thanks. It may be just because Travis installs superagent 3.5 and your fix is not backward compatible. Try with the latest version in package.json. If it works then we should create major version with a breaking change note.

@bmancini42
Copy link
Contributor Author

I don't think it's just Travis ... I think it's not a drop-in replacement. I am playing around with it to see if I can get it to work. But yes, it does seem like a major version type thing. Possibly it could gracefully revert if there's a way to detect which superagent API version is being used.

@bmancini42
Copy link
Contributor Author

Logic in the "old" _appendQueryString was processing the QS when it ran: https://github.com/visionmedia/superagent/blob/616cbb3507a7c81cc168891860ea060f3a040fd7/lib/node/index.js#L698

This code seems to be gone, period, after their refactor. Not sure what might be, or not, handling that now.

@bmancini42
Copy link
Contributor Author

bmancini42 commented Sep 7, 2017

@DevSide So, I have the tests working now, but not sure if this is the right solution. As mentioned above, when superagent switched from _appendQueryString to _finalizeQueryString in ladjs/superagent#1200, they removed code that was processing the "server" .query arg. Maybe they moved the functionality somewhere else, but I couldn't find it. My solution here was to replicate what they had been doing for the QS.

@bmancini42
Copy link
Contributor Author

@DevSide I just added a little bit for backwards compatibility. This passed the tests on both 3.5.2 and 3.6.0

@DevSide
Copy link
Contributor

DevSide commented Sep 11, 2017

You are right, they actually stringify query in prototype.request server side (https://github.com/visionmedia/superagent/pull/1200/files#diff-c24ce7e3da4c0e4ff811a2b6a76f8bd9R562) and they use _finalizeQueryString in prototype.end client side (https://github.com/visionmedia/superagent/pull/1200/files#diff-50cfa59973c04321b5da0c6da0fdf4feR677).

So what about:

if (this._finalizeQueryString) {
    isNodeServer ? this.request() : this._finalizeQueryString(): 
} else {
  // superagent < 3.6
  [...old code]
}

?

@bmancini42
Copy link
Contributor Author

Yeah that seems right. If I get a chance today I will play around with it and update the branch / PR

@bmancini42
Copy link
Contributor Author

@DevSide see latest. Uses Request.prototype.request

@DevSide
Copy link
Contributor

DevSide commented Sep 12, 2017

Good ! Last request, could you upgrade superagent to ^3.6.0 in peerDependencies and devDependencies please ?

@bmancini42
Copy link
Contributor Author

Done!

@jbox5
Copy link

jbox5 commented Sep 14, 2017

Is this PR ready to go? Would love a new version to stop the 'Unsupported' messages and traces spamming my console 👍

Copy link
Contributor

@DevSide DevSide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@fdubost fdubost merged commit 85c9feb into BedrockStreaming:master Sep 14, 2017
@fdubost
Copy link
Member

fdubost commented Sep 14, 2017

Thanks for your contribution ! 💪

@fdubost
Copy link
Member

fdubost commented Sep 14, 2017

Published on npm v3.6.0

@jbox5
Copy link

jbox5 commented Sep 14, 2017

Excellent - thanks for getting it progressed everyone.

@bmancini42
Copy link
Contributor Author

No problem -- we find superagent-mock very helpful, glad to give back

@bmancini42 bmancini42 deleted the changed-superagent-fn branch September 14, 2017 18:36
@bmancini42 bmancini42 restored the changed-superagent-fn branch September 14, 2017 18:40
@bmancini42 bmancini42 deleted the changed-superagent-fn branch September 14, 2017 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants