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

Conversation

mifi
Copy link
Contributor

@mifi mifi commented Jun 15, 2022

also make method private

pulled out from #3791

also make method private
Copy link
Contributor

@goto-bus-stop goto-bus-stop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't make breaking changes between Uppy/Companion communication unless we have a very good reason for it. Ideally Companion should support old Uppy versions for many years.

I think extraData is also used for XHR error reporting, it will send the response to the client so you can use the XHRUpload getResponseError to handle errors the same way for local and Companion uploads.

@Murderlon
Copy link
Member

We shouldn't make breaking changes between Uppy/Companion communication unless we have a very good reason for it. Ideally Companion should support old Uppy versions for many years.

How is this extraData currently used? How long has it been considered deprecated?

@goto-bus-stop
Copy link
Contributor

goto-bus-stop commented Jun 16, 2022

I haven't heard of extraData being deprecated at all, but i haven't paid that close attention either. The biggest problem i see here is that the error is no longer nested under an error key. But I updated my comment with how extraData (used to be?)/is used.

@goto-bus-stop
Copy link
Contributor

goto-bus-stop commented Jun 16, 2022

payload.response:

socket.on('error', (errData) => {
const resp = errData.response
const error = resp
? opts.getResponseError(resp.responseText, resp)
: Object.assign(new Error(errData.error.message), { cause: errData.error })
this.uppy.emit('upload-error', file, error)

@mifi
Copy link
Contributor Author

mifi commented Jun 16, 2022

I just found it a bit dirty that in the existing code, payload gets set to err.extraData, and then payload also gets an error property set on it, equal to err, which also contains extraData. And if extraData contains an error property, it will be overwritten.

const err = { message: 'test', extraData: { response: 'abc', error: 'something' } };
const { stack, ...serializedErr } = err;
console.log(JSON.stringify({ payload: { ...err.extraData, error: serializedErr } }, null, 2))

{
  "payload": {
    "response": "abc",
    "error": {
      "message": "test",
      "extraData": {
        "response": "abc",
        "error": "something"
      }
    }
  }
}

We can see that response gets duplicated, and error gets overwritten. That's why I wanted to clean up this. But I agree that it's not worth breaking the interface between companion and uppy client, which I didn't realize would happen. I have reverted the breaking change now.

@mifi mifi changed the title remove redundant extraData from error Minor cleanup Jun 16, 2022
@Murderlon Murderlon changed the title Minor cleanup Companion: make emitSuccess and emitError private Jun 20, 2022
@goto-bus-stop
Copy link
Contributor

The client doesn't use the nested payload.error.extraData, and the fact that it exists is definitely not intended, so it would be nice to clean that up. But we should be careful even about that since error objects may be exposed to users.

At some point we may have to consider ways to upgrade the HTTP/socket APIs with backwards compat, so newer clients can opt into newer implementations and old clients still work. This case is too small to justify that work I think.

@mifi
Copy link
Contributor Author

mifi commented Jun 27, 2022

Ok, I'll re-add the TODO then, hopefully in the future we can fix it

@mifi mifi merged commit abf9394 into 3.x Jun 27, 2022
@mifi mifi deleted the companion-3-remove-redundant-extraData-from-error branch June 27, 2022 05:03
github-actions bot added a commit that referenced this pull request Jul 6, 2022
| Package              |      Version | Package              |      Version |
| -------------------- | ------------ | -------------------- | ------------ |
| @uppy/companion      | 4.0.0-beta.1 | @uppy/transloadit    | 3.0.0-beta.2 |
| @uppy/locales        | 3.0.0-beta.2 | @uppy/robodog        | 3.0.0-beta.2 |
| @uppy/provider-views | 3.0.0-beta.2 | uppy                 | 3.0.0-beta.2 |

- example: fix `custom-provider` example (Antoine du Hamel / #3854)
- example: fix Vue3 example (Antoine du Hamel / #3774)
- @uppy/companion: remove deprecated duplicated metrics (Mikael Finstad / #3833)
- example: update CDN example (Antoine du Hamel / #3803)
- @uppy/companion: Companion 3 default to no s3 acl (Mikael Finstad / #3826)
- @uppy/companion: rewrite companion.app() to return an object (Mikael Finstad / #3827)
- @uppy/companion: remove companion provider compat api (Mikael Finstad / #3828)
- @uppy/companion: rewrite code for node >=14 (Mikael Finstad / #3829)
- @uppy/companion: remove chunkSize backwards compatibility (Mikael Finstad / #3830)
- @uppy/companion: Companion: make `emitSuccess` and `emitError` private (Mikael Finstad / #3832)
- @uppy/companion: do not use a default upload protocol (Mikael Finstad / #3834)
HeavenFox pushed a commit to docsend/uppy that referenced this pull request Jun 27, 2023
* remove redundant extraData from error

also make method private

* revert breaking change

* Update Uploader.js
HeavenFox pushed a commit to docsend/uppy that referenced this pull request Jun 27, 2023
| Package              |      Version | Package              |      Version |
| -------------------- | ------------ | -------------------- | ------------ |
| @uppy/companion      | 4.0.0-beta.1 | @uppy/transloadit    | 3.0.0-beta.2 |
| @uppy/locales        | 3.0.0-beta.2 | @uppy/robodog        | 3.0.0-beta.2 |
| @uppy/provider-views | 3.0.0-beta.2 | uppy                 | 3.0.0-beta.2 |

- example: fix `custom-provider` example (Antoine du Hamel / transloadit#3854)
- example: fix Vue3 example (Antoine du Hamel / transloadit#3774)
- @uppy/companion: remove deprecated duplicated metrics (Mikael Finstad / transloadit#3833)
- example: update CDN example (Antoine du Hamel / transloadit#3803)
- @uppy/companion: Companion 3 default to no s3 acl (Mikael Finstad / transloadit#3826)
- @uppy/companion: rewrite companion.app() to return an object (Mikael Finstad / transloadit#3827)
- @uppy/companion: remove companion provider compat api (Mikael Finstad / transloadit#3828)
- @uppy/companion: rewrite code for node >=14 (Mikael Finstad / transloadit#3829)
- @uppy/companion: remove chunkSize backwards compatibility (Mikael Finstad / transloadit#3830)
- @uppy/companion: Companion: make `emitSuccess` and `emitError` private (Mikael Finstad / transloadit#3832)
- @uppy/companion: do not use a default upload protocol (Mikael Finstad / transloadit#3834)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants