Open samuelms1 opened 8 years ago
Any updates on this? We're getting these errors too.
I ended up writing a small shim for the request module that fit our very targeted needs (implemented the very minimum that we use from the request module). I would strongly prefer the browser-request module, but to get around this bug we used the shim (note that it assumes jquery is on the page as $).
module.exports = {
get: function(options, callback){
$.ajax({
url: options.url,
timeout: options.timeout,
dataType: options.json === true ? 'json' : null,
error: function(jqXHR, textStatus, errorThrown) {
var errorMessage = "Error occurred while requesting " + options.url + ".";
if (textStatus) {
errorMessage += " Error status: " + textStatus;
if (errorThrown && errorThrown !== textStatus) {
errorMessage += " | Error Thrown: " + errorThrown;
}
}
var error = new Error(errorMessage);
if (textStatus === 'timeout') {
error.code === 'ETIMEDOUT'
}
error.status = jqXHR.status;
callback(error);
},
success: function(data, textStatus, jqXHR){
var responseObj = {
statusCode: jqXHR.status,
body: data
};
callback(null, responseObj, data);
}
});
}
};
In package.json I added this:
{
...
"browser": {
"request": "./lib/browserRequestShim.js"
}
...
}
Using the browser-request module in IE11 causes an InvalidStateError to occur.
The request code looks like this:
I have a nodejs module that requires the "request" module which on the browser (via browserify) uses the browser-request module. I've mapped this module correlation in my package.json like this:
Note that the request actually appears to work just fine, but IE logs an error
Here is a screenshot of the error in IE11 Developer Tools