formidable: FormidableError: no parser found

Support plan

  • Which support plan is this issue covered by? (Community, Sponsor, Enterprise): Community
  • Currently blocking your project/work? (yes/no): Yes
  • Affecting a production system? (yes/no): No

Context

  • Node.js version: v16.15.0
  • Release Line of Formidable (Legacy, Current, Next): Current
  • Formidable exact version: 2.0.1
  • Environment (node, browser, native, OS): Browser
  • Used with (popular names of modules): fs-extra, url, sanitizeFilename, webpack

What are you trying to achieve or the steps to reproduce?

const formidable = require("formidable");

const parseFormData = (req, { maxFieldsSize, maxFileSize }) => {
	// Occurs regardless of whether I use the commented-out syntax or the active one
	// const form = new formidable.IncomingForm();
	// form.maxFieldsSize = maxFieldsSize;
	// form.maxFileSize = maxFileSize;
	// form.multiple = true;

	const form = formidable({
		multiple: true,
		maxFieldsSize,
		maxFileSize,
	});

	return new Promise((resolve, reject) => {
		form.parse(req, (err, fields, files) => {
			return err ? reject(err) : resolve({ fields, files });
		});
	});
};

What was the result you got?

FormidableError: no parser found, with a code of 1003 and an httpCode of 415.

This then gives the Express error:

RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: 1003

What result did you expect?

I expect to be able to parse the passed file, although I am currently unsure of how to do so. I am working on an inherited project and this seems to have worked before, and researching the error message has not lead to a solution.

Any help would be greatly appreciated!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

The error means the content type is not recognized amongst the 3 that can be parsed by formidable.