MaTTo's avatar
Level 4

Sending POST request catches error but no error occured

I have an application in production, which is used by multiple users - they always access the app from the mobile phone (in this case it's from Android 6.0.1 with Chrome Mobile 71.0.3578). Inside the app, they have to take a photo of specific thing and upload it. I created a Vue component with simple INPUT which on click launches Photo app or opens gallery to pick image. After that, the image is being processed and stored on the server with AXIOS. And here is where AXIOS catches me an error but no error has occurred.

                axios.post('/stations/' + this.controlPoint.station_id + '/controls/' + this.controlPoint.id + '/entries', {
                    point: this.controlPoint,
                    image: image,
                    imageDate: lastChanged,
                    entry: this.controlPoint.this_week_entry
                }, {timeout: 999999}).then(res => {
                    this.controlPoint.entry_id = res.data.entry.id;
                    this.controlPoint.entryStatus = res.data.entry.status;
                    this.uploading = false;
                }).catch(err => {
                    this.uploading = false;
                    console.log(err);
                    alert("Napaka pri nalaganju slike - prosimo, poskusite ponovno");

                    // TODO: Probably not needed?
                    axios.post('/api/log-error', {
                        message: 'Error uploading entry Image',
                        exception: err,
                        station: this.controlPoint.station_id,
                        file: 'ControlPoint.vue'
                    });
                });

And the error that is logged with separate POST request from catch block:

Message
Error uploading entry Image

Level
ERROR

exception
[]

file
ControlPoint.vue

station
21

The problem is I am unable to reproduce the error in any way so it is really hard to debug it. The backend is laravel and nothing is shown in laravel.log.

I have read that if an error occurs in "then" block, it would also catch an error inside catch block but I have such a simple code in "then" block that is almost impossible that anything happens.

The user just refreshes the page after each upload and of course, the image is safely and correctly stored on the server.

What else to check? :)

Thank you in advance!

0 likes
0 replies

Please or to participate in this conversation.