-
Notifications
You must be signed in to change notification settings - Fork 259
Description
I have a page with the following ajax post request:
$.ajax({
type: "POST",
url: "/my/some_id/path/create",
data: some_data,
success: function () {
//Do something
},
fail: function () {
console.log("fail");
}
});
It was working just fine until a couple days ago, just before I tried to use this library. The library did indeed work as expected, but using it seemed to have negative consequences on existing functionality. The previously mentioned request hanged for about a minute. Then, although the browser would not receive anything, my app would raise this error:
Error: request aborted
at IncomingMessage.onAborted (/home/cavpollo/my_app/node_modules/body-parser/node_modules/raw-body/index.js:269:10)
at emitNone (events.js:68:13)
at IncomingMessage.emit (events.js:167:7)
at IncomingMessage.wrapped (/home/cavpollo/my_app/node_modules/newrelic/lib/transaction/tracer/index.js:161:28)
at IncomingMessage.wrappedEmit [as emit] (/home/cavpollo/my_app/node_modules/newrelic/lib/transaction/tracer/index.js:198:46)
at abortIncoming (_http_server.js:281:11)
at Socket.serverSocketCloseListener (_http_server.js:294:5)
at emitOne (events.js:83:20)
at Socket.emit (events.js:170:7)
at TCP._onclose (net.js:470:12)
After some debugging I came to realize that the problem was this line in my app initialization:
var express = require('express');
var fileUpload = require('express-fileupload');
var bodyParser = require('body-parser');
var app = express();
//Some irrelevant code
app.use(fileUpload()); // <------------- This line
//Some more irrelevant code
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
Just commenting the line allowed me to do the Ajax Post call without problems... so then I thought, what if we switch things around?
var express = require('express');
var fileUpload = require('express-fileupload');
var bodyParser = require('body-parser');
var app = express();
//Some irrelevant code again
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
app.use(fileUpload());
It turns out that initializing things this way results in no errors and things working as expected.
Just a friendly heads up to anybody who stumbles on this problem. I was using version express-fileupload verison 0.0.5, express 4.14.0 and body-parser 1.13.3, if it is of any help.