-
-
Notifications
You must be signed in to change notification settings - Fork 681
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
Use formidable upload files, always get "Error Request Aborted" #285
Comments
same here for big file uploads (1mb - 15mb) |
+1 |
yep this is crashing my site (image uploads) every once in a while... not good. |
Has anyone found a solution? |
It is the client that is aborting, not the server. It's an error you can always get and which you must handle. It's not a bug in formidable. |
+1 |
Same here.. happening with files lesser than 100 kb.. Anyone handled this case? |
I see this for files as small as 10kb. My client aborts the request after 2 mins latency. So there is something here at play. Removing the express bodyparser didn't helped either |
Same here....but I find the reason is that I use ths multer module for parsing multipart/form-data. So that is resulting in the formidable can't parse correctly. |
to disable body-parser for multipart/form-data in your router exmple solution of nodejs
|
+1 Removing the express bodyparser didn't helped either |
Very weird this issue!! I believe it is Express or browser problem, because I did many test with Firefox, Chrome and Chrome Canary. |
+1 how to solve it |
how to sovle it. |
try to delete this in your app.js. |
Getting rid of the app.use(bodyParser.json()); helped. |
I'm trying to use formidable in a firebase function, and am getting this error for every request. |
Same problem here, but it is very strange that my app is running perfectly on local machine, but when i upload that on c9 and my digital ocean droplet it started to giving this error. i remove body parser as well and try this from firefox also, but no luck. |
What if I need bodyparser and formidable and i can't remove bodyparser from my app? What I should do? |
I have many more post request routes for which I am using body parser and in few of them I need formidable. What should I do? |
Has anyone found a solution with Formidable and Firebase? For me it works locally, but not in the deployed instance. (Using FormData and html5 fetch.) I wonder if that depends on where I store the uploaded files. I am currently using "./../mytempdir". Is that a place I can use? (I first tried "./mytempdir", but that dispatches a signal to Node.js that some files has changed.) |
Hm. Pretty weird, really. But most of the comments are because using the Express v3. Also, is the directories writable? Those remote servers are paranoic about security and who knows what they do to limit permissions. I'm mostly sure that that's not the problem, but make sure to check or make programatically directories to have read/write permissions. |
I've seen this problem when using some php server along with the express stuff (nginx with fpm module as reverse proxy, for say). I would try to narrow the problem down (also talking to myself on this point) to see what is exactly the problem here. Any ideas on how to trace the problem in an e2e fashion? edit: |
The following answer seems to be helpful for developers who want to receive form data on Firebase Cloud Functions. |
One way to solve it is to using a GET request instead and disguise it as a POST or PUT by sending params. And to retrieve it from your server file: |
Has anyone found a solution with Formidable and Firebase? |
you have to use form-data instead of raw while passing the parameter in body... |
Same issue here, using Formidable and Firebase. In local environment (and it's working on production). It maaay be a permission problem. Not sure. |
I just published formidable-serverless - it imports formidable as a dependency and modifies the handlers to support preprocessed request bodies (built-in to many serverless environments). I'm using it in production with Firebase @BrodaNoel @brodwen83 @lborgman @nicholasstephan The usage/API is exactly the same. Hope that helps. |
@Amit-A great, but looking on it.. it isn't the best API decision idea. Because it's patching only the |
@tunnckoCore that could be a nice way of doing it, but I wonder about versioning risk... if there's a breaking change in formidable, and we pass the new formidable to the function, it could return a broken parse method vs. the current implementation: importing formidable, enforcing the version in package.json, then exporting it. |
You will (need) to listen for new versions anyway, even with the current approach. If here come breaking change it will come to you too anyway. Also, I think no major release is come anytime soon. |
I have problem, i have nodejs api retreive upload from android phone.. |
@programmerpinggiran can you try the |
@tunnckoCore ill try it and report here after few days later |
@tunnckoCore error still exist
|
@programmerpinggiran from your logs it seems like the error is coming from elsewhere. While the
The event is emitted elsewhere:
You're using PM2 so I'm assuming you're not in a serverless environment. Will need more information:
|
@Amit-A thanks, this is a great library.
app.post('/v2/api/oururlpath', function(request, res) {
var form = new formidable.IncomingForm();
var email;
form.keepExtensions = true;
form.multiples = true;
files = [],
fields = [];
form.uploadDir = '../../var/www/html/uploads/';
form.on('field', function(field, value) {
fields.push([field, value]);
console.log(field + " val " + value);
email = value;
})
form.on('file', function(field, file) {
var oldpath = file.path;
var newpath = "../../var/www/html/uploads/" + file.name;
var file_path = "http://domain:port/urlpath?img=" + file.name;
mv(oldpath, newpath, function(err) {
if (err) {
console.log("Foto error " + err);
throw err;
} else {
var fotoupdate1;
if (file.name.indexOf("profile1") > -1) {
fotoupdate1 = {
email: email,
foto1: file_path,
};
} else if (file.name.indexOf("profile2") > -1) {
fotoupdate1 = {
email: email,
foto2: file_path,
};
} else if (file.name.indexOf("profile3") > -1) {
fotoupdate1 = {
email: email,
foto3: file_path,
};
} else if (file.name.indexOf("profile4") > -1) {
fotoupdate1 = {
email: email,
foto4: file_path,
};
} else if (file.name.indexOf("profile5") > -1) {
fotoupdate1 = {
email: email,
foto5: file_path,
};
} else if (file.name.indexOf("profile6") > -1) {
fotoupdate1 = {
email: email,
foto6: file_path,
};
}
//fotoupdate1 is for sql stuff
}
});
// console.log("--------------- END ---------------");
})
form.on('end', function() {
console.log('done upload photo');
return res.json({
success: true,
status: "1",
hasil: "file uploaded successfully",
});
});
form.parse(request);
});
const bodyParser = require('body-parser');
app.use(bodyParser.json({
limit: '50mb'
}));
app.use(bodyParser.urlencoded({
limit: '50mb',
extended: true
})); our android client using okhttp public String uploadImage(String email,String url) {
);
OkHttpClient httpClient = new OkHttpClient();
MultipartBody.Builder requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("email", session.getEmailuser());
if (filefoto1 != null) {
requestBody.addFormDataPart("foto1", email + "_profile1.png",
RequestBody.create(MEDIA_TYPE_PNG, new File(filefoto1.getPath())));
}
if (filefoto2 != null) {
requestBody.addFormDataPart("foto2", email + "_profile2.png",
RequestBody.create(MEDIA_TYPE_PNG, new File(filefoto2.getPath())));
}
if (filefoto3 != null) {
requestBody.addFormDataPart("foto3", email + "_profile3.png",
RequestBody.create(MEDIA_TYPE_PNG, new File(filefoto3.getPath())));
}
if (filefoto4 != null) {
requestBody.addFormDataPart("foto4", email + "_profile4.png",
RequestBody.create(MEDIA_TYPE_PNG, new File(filefoto4.getPath())));
}
if (filefoto5 != null) {
requestBody.addFormDataPart("foto5", email + "_profile5.png",
RequestBody.create(MEDIA_TYPE_PNG, new File(filefoto5.getPath())));
}
if (filefoto6 != null) {
requestBody.addFormDataPart("foto6", email + "_profile6.png",
RequestBody.create(MEDIA_TYPE_PNG, new File(filefoto6.getPath())));
}
RequestBody req = requestBody.build();
final Request request = new Request.Builder()
.url(url)
.post(req)
.build();
Response response = null;
try {
response = httpClient.newCall(request).execute();
return response.body().string();
} catch (IOException e) {
return null;
}
} |
The @Amit-A 's |
@programmerpinggiran there's a lot going on there... have you tried unit testing the API endpoint? Once you know the specific fail cases it'll be easier to debug. While formidable-serverless should be fine alongside body-parser, if you're not in a serverless environment I would separate body-parser from formidable. This is because body-parser can emit its own errors and make it difficult to debug in the mixup, and the double parsing can be an unnecessary performance drag. You can do this by providing body-parser as middleware to only the API endpoints that need it (excluding the endpoint that uses formidable). |
|
@lborgman @BrodaNoel @brodwen83 & others. Please try @GrosSacASac lets see what's the state with latest (formidable@canary) versions of both Formidable and Express. Then we can just document how to use it with Express, more correctly. |
koa2 meets the same problem, when using bodyParser with formidable. |
what you removed? Koa2 or Formidable@canary? Do you mean that the problem continue even with I'm going to publish v2 on 29th or 1st, so.. We may continue after that if it's still a problem. |
sorry, i mean removing koa-body's bodyParser, i use [email protected] and latest koa2. Now everything works, thx |
Cool! One last thing, do you mean with |
I'm going to fix that in #594 and v2. |
@Amit-A Thx, that really helped |
May be we need not delete the
|
My problem was that after 70 to 90s request was aborted. I want to upload big files (2GB and more) to the api. But I was unable to upload bigger file then 2,8 GB on local host while testing. I moved from koa2 to express (only because I understand express better). But still have the same error. At the end I did try running tests in different node versions and I've succeed with version 15. Give it a try. |
const server = http.createServer((request, response) => {
request.on(`error`, console.error.bind(console, `request error`));
response.on(`error`, console.error.bind(console, `response error`)); |
this works for me
|
Error Request Aborted
.I want to know why I got aborted and how to debug it.
The text was updated successfully, but these errors were encountered: