I have a simple function that fetches some data, shows it to the user (on a chart), wait for 10 minutes and starts again. After some time I get this error
Error: timeout of 0ms exceeded
I found this supposed to happen if it can't connect to the internet, which cannot be the case.
Is chrome doing this maybe? I think it might freeze the app or something.
Here is the simple function:
updateReports() {
// checks for new data, waits the given time, and checks again.. forever
this.$VKS.Read('Report', { filter: { shared: this.user }})
.then(reports => {
this.reports = reports // show the data to the user
setTimeout(() => {
this.updateReports() // start again
}, 1000 * 60 * 10) // 10 minutes
}).catch(err => console.error(err))
},
Thank you for your help!
if you get error(in this case Timeout) your codes never retry. you need to do the same in catch statement:
updateReports() {
// checks for new data, waits the given time, and checks again.. forever
this.$VKS.Read('Report', { filter: { shared: this.user }})
.then(reports => {
this.reports = reports // show the data to the user
setTimeout(() => {
this.updateReports() // start again
}, 1000 * 60 * 10) // 10 minutes
}).catch(err => {
console.error(err);
setTimeout(() => {
this.updateReports() // start again
}, 1000 * 60 * 10) // 10 minutes
})
},