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

Breaking change: 2.50.0 #1663

Closed
samhmills opened this issue Jun 28, 2015 · 4 comments
Closed

Breaking change: 2.50.0 #1663

samhmills opened this issue Jun 28, 2015 · 4 comments

Comments

@samhmills
Copy link

Hi there,

I'm really struggling to update a private module of mine past v2.49.0 because 2.50.0 seems to have a breaking change in my code.

Through request debug each version shows near identical data. Logging the request objects that are sent shows identical data, yet the response from the site who's API I am using fails.

Does anyone have any knowledge of what changed in 2.50.0 to create this I am having?

var opts = {
        method: type,
        url: settings.gatewayUrl + loc,
        headers: {
            Accept: "application/json, text/javascript, */*; q=0.01",
            Cookie: this.cookies,
            "Content-Type": "application/json"
        },
        callbacks:{
            success: successCallback,
            failure: failureCallback
        }
};
if (data) {
        opts.data = JSON.stringify(data);
}

(Opts is passed as obj to the send function)

Gateway.prototype.send = function (obj) {
    var req = {
        method: obj.method,
        url: obj.url,
        headers: obj.headers,
        json: true
    };
    if (typeof obj.data !== "undefined"){
        req.body = obj.data;
    }
    request(req, function (err, res, body) {
        if (err) {
            if (typeof obj.callbacks.failure === 'function') {
                obj.callbacks.failure(err);
            }
        }
        if (typeof obj.callbacks.success === 'function') {
            obj.callbacks.success(body);
            console.log(req);
            console.log(body);
        }
    })
};

Thanks in advance anyone who may have an idea as per what is causing such a difference between the two minor versions of request. All requests go through the send function, GET's work fine, POST's seem to be the ones to break. It is not a cookie issue, as the GET's correctly return. POST's respond with a server code of "requestError", even though I know that doesn't really mean much...

@simov
Copy link
Member

simov commented Jun 28, 2015

Without reading your bug report - can you switch to a newer version and test again? 2.50 is broken!

@samhmills
Copy link
Author

Sorry, I should have said, I originally tried to update to the very latest (v2.58.0) in order to fix this bug: #1522 within my module.

Every version after 2.50.0 has this change in it that breaks for me. I know we're dealing with a third party service in this issue, I'm just trying to track down what would cause them to provide a different response, purely from a change in the module. The breaking versions for me are: 2.50.0 - 2.58.0 (latest npm)

Thanks for you lightning fast response!

@simov
Copy link
Member

simov commented Jun 28, 2015

You should either pass your object via json:{object} or body:{object} if json:true from the docs

body - entity body for PATCH, POST and PUT requests. Must be a Buffer or String, unless json is true. If json is true, then body must be a JSON-serializable object.

The documentation wasn't changed, so I'm assuming that this behavior was fixed in #1310

As for the breaking change - while we try to minimize braking changes, it happens, plus currently request does not follow the semver semantics, so your best option would be to stick with specific version of request, and always run your tests after upgrading to a newer one.

@samhmills
Copy link
Author

Fantastic!

Thank you, that was the change I was missing. Running on v2.58.0 without issues now.

Thanks for your time!

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

No branches or pull requests

2 participants