{"id":17427,"library":"connect-busboy","title":"Connect Busboy Middleware","description":"connect-busboy is a middleware for Node.js Connect and Express applications, designed to parse `multipart/form-data` requests, primarily for file uploads and complex form data. It acts as a wrapper around the powerful, streaming `busboy` parser, providing a simpler API for integration into the middleware stack. The current stable version is 1.0.0. The package has seen no updates in over four years (last published April 2022), indicating a maintenance-only status with a very slow release cadence. While it provides a straightforward way to handle multipart requests, more actively maintained alternatives like `multer` or `express-fileupload` are often preferred for modern Express applications due to ongoing support and feature development.","status":"maintenance","version":"1.0.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/mscdex/connect-busboy","tags":["javascript","connect","middleware","uploads","forms","multipart","form-data"],"install":[{"cmd":"npm install connect-busboy","lang":"bash","label":"npm"},{"cmd":"yarn add connect-busboy","lang":"bash","label":"yarn"},{"cmd":"pnpm add connect-busboy","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core library for parsing multipart/form-data requests. connect-busboy is a middleware wrapper around busboy.","package":"busboy","optional":false},{"reason":"connect-busboy is designed as middleware for Connect-compatible frameworks like Connect and Express.","package":"connect","optional":true}],"imports":[{"note":"The package is primarily designed for CommonJS. While some bundlers might allow `import`, direct ESM usage is not officially supported or exemplified.","wrong":"import busboyMiddleware from 'connect-busboy';","symbol":"busboyMiddleware","correct":"const busboyMiddleware = require('connect-busboy');"},{"note":"The package exports a function, not a class or named export for Busboy itself. The function returns a middleware. The underlying Busboy instance is exposed via `req.busboy`.","wrong":"import { Busboy } from 'connect-busboy';","symbol":"Busboy","correct":"const busboy = require('connect-busboy'); app.use(busboy());"}],"quickstart":{"code":"const express = require('express');\nconst busboy = require('connect-busboy');\nconst path = require('path');\nconst fs = require('fs');\n\nconst app = express();\n\n// Default options, no immediate parsing\napp.use(busboy({\n  highWaterMark: 2 * 1024 * 1024, // Set file stream high water mark to 2MB\n  limits: {\n    fileSize: 10 * 1024 * 1024, // Limit uploaded file size to 10MB\n  }\n}));\n\napp.get('/', (req, res) => {\n  res.writeHead(200, { 'Connection': 'close' });\n  res.end(`\n    <form method=\"POST\" enctype=\"multipart/form-data\">\n      <input type=\"file\" name=\"uploadFile\"><br/>\n      <input type=\"text\" name=\"description\"><br/>\n      <input type=\"submit\" value=\"Upload\">\n    </form>\n  `);\n});\n\napp.post('/', (req, res) => {\n  if (!req.busboy) {\n    return res.status(400).send('No busboy instance on request. Check headers and method.');\n  }\n\n  req.busboy.on('file', (name, file, info) => {\n    const { filename, encoding, mimeType } = info;\n    console.log(`File [${name}]: filename: %j, encoding: %j, mimeType: %j`, filename, encoding, mimeType);\n\n    const saveTo = path.join(__dirname, 'uploads', filename);\n    console.log(`Saving file to: ${saveTo}`);\n    file.pipe(fs.createWriteStream(saveTo));\n\n    file.on('end', () => {\n      console.log(`File [${name}] finished`);\n    });\n  });\n\n  req.busboy.on('field', (name, value, info) => {\n    console.log(`Field [${name}]: value: %j`, value);\n  });\n\n  req.busboy.on('finish', () => {\n    console.log('Done parsing form!');\n    res.status(200).send('Upload successful!');\n  });\n\n  req.busboy.on('error', (err) => {\n    console.error('Busboy error:', err);\n    res.status(500).send('File upload failed.');\n  });\n\n  req.pipe(req.busboy);\n});\n\nconst PORT = process.env.PORT || 3000;\n\n// Ensure 'uploads' directory exists\nconst uploadsDir = path.join(__dirname, 'uploads');\nif (!fs.existsSync(uploadsDir)) {\n  fs.mkdirSync(uploadsDir);\n}\n\napp.listen(PORT, () => {\n  console.log(`Server listening on http://localhost:${PORT}`);\n});","lang":"javascript","description":"This quickstart sets up an Express server to handle file uploads using connect-busboy, demonstrating how to configure middleware options, listen for file and field events, and save uploaded files to disk."},"warnings":[{"fix":"For new projects or if active maintenance is crucial, consider alternatives like `multer` or `express-fileupload`.","message":"The `connect-busboy` package has not been updated in over 4 years (last published April 2022), indicating very limited ongoing maintenance or bug fixes. Users should be aware that new features or patches for modern Node.js versions or potential security vulnerabilities are unlikely. Consider more actively maintained alternatives for new projects.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure your Node.js version is >=10.16.0. Update event handler signatures for `file` and `field` events to destructure the `info` object for properties like `filename` and `mimeType` instead of separate arguments.","message":"connect-busboy v1.0.0 depends on `busboy` ^1.0.0. The underlying `busboy` library introduced breaking changes in its v1.0.0 release (December 2021), which impact users of connect-busboy. These include: minimum Node.js version requirement changed to >=10.16.0; parameters passed to `file` and `field` event handlers are now consolidated into a single `info` object (containing `filename`, `encoding`, `mimeType`); and stricter header parsing for `multipart/form-data` requests.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always check for `if (req.busboy)` before attempting to use it. Ensure client requests use appropriate HTTP methods (e.g., POST) and `Content-Type` headers for multipart data. Refer to the 'Troubleshooting' section in the package README.","message":"connect-busboy will only attach a `busboy` instance to `req.busboy` if specific conditions are met: the request method is not GET or HEAD, the `Content-Type` header is `application/x-www-form-urlencoded` or starts with `multipart/*`, and the `Content-Length` header is defined or chunked transfer encoding is in use. If `req.busboy` is `undefined`, these conditions were not met.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Verify that the HTTP request method is not GET or HEAD, the 'Content-Type' header is set to 'multipart/form-data' or 'application/x-www-form-urlencoded', and 'Content-Length' is defined or chunked transfer encoding is used. Add a check `if (req.busboy) { ... }` before using it.","cause":"The `req.busboy` object is undefined because the incoming HTTP request did not meet the criteria for connect-busboy to process it as multipart/form-data.","error":"TypeError: Cannot call method 'on' of undefined"}],"ecosystem":"npm","meta_description":null}