Socket
Socket
Sign inDemoInstall

@fastify/multipart

Package Overview
Dependencies
Maintainers
20
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastify/multipart - npm Package Compare versions

Comparing version 8.1.0 to 8.2.0

35

index.js

@@ -202,4 +202,12 @@ 'use strict'

handle((val) => {
if (val instanceof Error) return reject(val)
resolve(val)
if (val instanceof Error) {
if (val.message === 'Unexpected end of multipart data') {
// Stop parsing without throwing an error
resolve(null)
} else {
reject(val)
}
} else {
resolve(val)
}
})

@@ -228,6 +236,6 @@ })

.on('file', onFile)
.on('end', cleanup)
.on('finish', cleanup)
.on('close', cleanup)
.on('error', onEnd)
.on('end', onEnd)
.on('finish', onEnd)
.on('error', cleanup)

@@ -237,3 +245,3 @@ bb.on('partsLimit', function () {

onError(err)
process.nextTick(() => onEnd(err))
process.nextTick(() => cleanup(err))
})

@@ -244,3 +252,3 @@

onError(err)
process.nextTick(() => onEnd(err))
process.nextTick(() => cleanup(err))
})

@@ -251,3 +259,3 @@

onError(err)
process.nextTick(() => onEnd(err))
process.nextTick(() => cleanup(err))
})

@@ -378,14 +386,11 @@

function onEnd (err) {
cleanup()
ch(err || lastError)
}
function cleanup (err) {
request.unpipe(bb)
// in node 10 it seems that error handler is not called but request.aborted is set
if ((err || request.aborted) && currentFile) {
currentFile.destroy()
currentFile = null
}
ch(err || lastError || null)
}

@@ -392,0 +397,0 @@

{
"name": "@fastify/multipart",
"version": "8.1.0",
"version": "8.2.0",
"description": "Multipart plugin for Fastify",

@@ -9,3 +9,3 @@ "main": "index.js",

"dependencies": {
"@fastify/busboy": "^1.0.0",
"@fastify/busboy": "^2.1.0",
"@fastify/deepmerge": "^1.0.0",

@@ -20,6 +20,6 @@ "@fastify/error": "^3.0.0",

"@fastify/swagger": "^8.10.1",
"@fastify/swagger-ui": "^2.0.1",
"@fastify/swagger-ui": "^3.0.0",
"@types/node": "^20.1.0",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"benchmark": "^2.1.4",

@@ -26,0 +26,0 @@ "climem": "^2.0.0",

@@ -375,3 +375,3 @@ # @fastify/multipart

If you want to use `@fastify/multipart` with `@fastify/swagger` and `@fastify/swagger-ui` you must add a new type called `isFile` and use custom instance of validator compiler [Docs](https://www.fastify.io/docs/latest/Reference/Validation-and-Serialization/#validator-compiler).
If you want to use `@fastify/multipart` with `@fastify/swagger` and `@fastify/swagger-ui` you must add a new type called `isFile` and use custom instance of validator compiler [Docs](https://fastify.dev/docs/latest/Reference/Validation-and-Serialization/#validator-compiler).

@@ -378,0 +378,0 @@ ```js

@@ -637,1 +637,56 @@ 'use strict'

})
test('should not freeze when error is thrown during processing', { skip: process.versions.node.startsWith('14') }, async function (t) {
t.plan(2)
const app = Fastify()
app
.register(multipart)
app
.post('/', async (request, reply) => {
const files = request.files()
for await (const { file } of files) {
try {
const storage = new stream.Writable({
write (chunk, encoding, callback) {
// trigger error:
callback(new Error('write error'))
}
})
await pump(file, storage)
} catch {}
}
return { message: 'done' }
})
await app.listen()
const { port } = app.server.address()
const form = new FormData()
const opts = {
hostname: '127.0.0.1',
port,
path: '/',
headers: form.getHeaders(),
method: 'POST'
}
const req = http.request(opts)
try {
form.append('upload', fs.createReadStream(filePath))
form.pipe(req)
} catch {}
const [res] = await once(req, 'response')
t.equal(res.statusCode, 200)
res.resume()
await once(res, 'end')
t.pass('res ended successfully!')
await app.close()
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc