{"message":"Cannot read property 'length' of null"} is getting appended to the response of our API responses when we use 2.3.3-beta.
Following is the sample repsonse:
{ "args": {}, "headers": { "Accept": "*/*", "Accept-Encoding": "gzip, deflate, sdch", "Accept-Language": "en-US,en;q=0.8,mi;q=0.6", "Authorization": "*******", "Cache-Control": "no-cache", "Host": "httpbin.org", "Postman-Token": "25d77b10-2fe9-539f-926c-c71e6c35f568", "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/36", "X-Authorization-Claims": "******", "X-Requested-With": "Apigee Edgemicro" }, "origin": "x.x.x.x", "url": "http://httpbin.org/get" } {"message":"Cannot read property 'length' of null"}
Our APIs used to respond properly with the prior versions of Edge Microgateway.
I am getting this error because of the custom plugin that we are using :
'use strict'; module.exports.init = function(config, logger, stats) { return { onend_response: function(req, res, data, next) { req.url = '*****'; // oauth if (req.token) { req.token.access_token = '*****'; } next(null, null); } }; }
If change the next(null, null) to next(null, res) it works fine. is it the expected behaviour ?
Definitely not. I'll look into this issue.
I've replicated the issue, and have a candidate fix. For now I'd recommend passing the data parameter as the second argument to the callback.
You can monitor the progress of the change here: https://github.com/apigee/microgateway-core/pull/55
Thanks you Matthew 🙂