@uppy/companion: remove error.extraData (#5198)

See discussion in #3832.
This commit is contained in:
Mikael Finstad 2024-05-24 23:45:55 +02:00 committed by Antoine du Hamel
parent dceda79a97
commit 2f21ce99c9
No known key found for this signature in database
GPG key ID: 21D900FFDB233756
2 changed files with 7 additions and 9 deletions

View file

@ -18,6 +18,9 @@ These cover all the major Uppy versions and how to migrate to them.
`getExtraGrantConfig`.
- Endpoint `GET /s3/params` now returns `{ method: "POST" }` instead of
`{ method: "post" }`. This will not affect most people.
- The Companion [`error` event](https://uppy.io/docs/companion/#events) now no
longer includes `extraData` inside the `payload.error` property. `extraData`
is (and was also before) included in the `payload`.
### `@uppy/companion-client`

View file

@ -49,11 +49,7 @@ function sanitizeMetadata(inputMetadata) {
}
class ValidationError extends Error {
constructor(message) {
super(message)
this.name = 'ValidationError'
}
name = 'ValidationError'
}
/**
@ -340,7 +336,7 @@ class Uploader {
return
}
logger.error(err, 'uploader.error', this.shortToken)
this.#emitError(err)
await this.#emitError(err)
} finally {
emitter().removeAllListeners(`pause:${this.token}`)
emitter().removeAllListeners(`resume:${this.token}`)
@ -487,14 +483,13 @@ class Uploader {
*/
async #emitError(err) {
// delete stack to avoid sending server info to client
// todo remove also extraData from serializedErr in next major,
// see PR discussion https://github.com/transloadit/uppy/pull/3832
// @ts-ignore
const { serializeError } = await import('serialize-error')
const { stack, ...serializedErr } = serializeError(err)
const dataToEmit = {
action: 'error',
// @ts-ignore
payload: { ...err.extraData, error: serializedErr },
payload: { error: serializedErr },
}
this.saveState(dataToEmit)
emitter().emit(this.token, dataToEmit)