Skip to content
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

Companion: make emitSuccess and emitError private #3832

Merged
merged 3 commits into from Jun 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/@uppy/companion/src/server/Uploader.js
Expand Up @@ -295,15 +295,15 @@ class Uploader {
const ret = await this.uploadStream(stream)
if (!ret) return
const { url, extraData } = ret
this.emitSuccess(url, extraData)
this.#emitSuccess(url, extraData)
} catch (err) {
if (err instanceof AbortError) {
logger.error('Aborted upload', 'uploader.aborted', this.shortToken)
return
}
// console.log(err)
logger.error(err, 'uploader.error', this.shortToken)
this.emitError(err)
this.#emitError(err)
} finally {
emitter().removeAllListeners(`pause:${this.token}`)
emitter().removeAllListeners(`resume:${this.token}`)
Expand Down Expand Up @@ -460,7 +460,7 @@ class Uploader {
* @param {string} url
* @param {object} extraData
*/
emitSuccess (url, extraData) {
#emitSuccess (url, extraData) {
const emitData = {
action: 'success',
payload: { ...extraData, complete: true, url },
Expand All @@ -473,9 +473,10 @@ class Uploader {
*
* @param {Error} err
*/
emitError (err) {
#emitError (err) {
// delete stack to avoid sending server info to client
// todo remove also extraData from serializedErr in next major
// todo remove also extraData from serializedErr in next major,
// see PR discussion https://github.com/transloadit/uppy/pull/3832
const { stack, ...serializedErr } = serializeError(err)
const dataToEmit = {
action: 'error',
Expand Down