I have a endpoint in koa, that loads much data from the database and then calculates some results based on it. This can take some seconds.
What happens to a request, if the browser cancels it? Like the browser tab gets closed etc.
For example, would cache.c
be filled even if the browser canceled or is koa smart enough to simply stop any actions it started for this request?
const cache = {}
router.get('/data', function *(next) {
if (cache.c) return this.body = cache.c
// somewhere here the browser cancels the request
//---
const a = yield db.getA()
const b = yield db.getB()
cache.c = yield calculateC(a,b)
//---
this.body = cache.c
})