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

UPLOADED event fires off when the responseCode is 4xx #225

Open
nvahalik opened this issue May 2, 2022 · 6 comments
Open

UPLOADED event fires off when the responseCode is 4xx #225

nvahalik opened this issue May 2, 2022 · 6 comments

Comments

@nvahalik
Copy link
Contributor

nvahalik commented May 2, 2022

We are getting these when doing an upload:

{
  "id": "d2dc0170-c4ae-11ec-9b23-f318f271c241",
  "eventId": "d2dc0170-c4ae-11ec-9b23-f318f271c241",
  "state": "UPLOADED",
  "serverResponse": "<html>\\n<head><title>413 Request Entity Too Large</title></head>\\n<body>\\n<center><h1>413 Request Entity Too Large</h1></center>\\n<hr><center>cloudflare</center>\\n</body>\\n</html>\\n",
  "statusCode": 413
}

This should be error, but instead the state is UPLOADED.

@zfir
Copy link
Member

zfir commented May 4, 2022

Hello @nvahalik,

On which platform are you having this problem?

Regards,
Zafir.

@nvahalik
Copy link
Contributor Author

nvahalik commented May 4, 2022 via email

@ombr
Copy link
Collaborator

ombr commented May 5, 2022

I think this is expected. You should check the status code on your side. You will only get a failure if the request did not went through.

@nvahalik
Copy link
Contributor Author

nvahalik commented May 5, 2022

@ombr This makes no sense, though. Any response >= 400 is an error. A 4xx is a client error and a 5xx is a server error.

This is a bug in the plugin.

@ombr
Copy link
Collaborator

ombr commented May 5, 2022

@nvahalik I understand this is not intuitive. This library was created from this library and was following the same principle (at that time) gotev/android-upload-service#259 (you should check the issue).

You are more than welcome to submit a pull-request for this.

One thing to keep in mind is that we might want to save the response even if the status code is > 400 as we might want to use it to better understand the error.

Thanks.

Luc

nvahalik added a commit to 1stphorm/cordova-plugin-background-upload that referenced this issue Jul 22, 2024
Set the error flag based on the success of the request.
@nvahalik
Copy link
Contributor Author

For anyone coming here and seeing this, I've fixed this (along with a few other issues) in our version of the plugin: https://github.com/1stphorm/cordova-plugin-background-upload

The fix is actually very simple. Just use !response.isSuccessful(): 1stphorm@64a0b15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants