mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-14 01:36:37 +00:00
Merge pull request #14501 from overleaf/jpa-streaming-log-noise
[web] CompileController: ignore noisy spurious error GitOrigin-RevId: 8885286a5e06bfa38bc70d98b703f52a1269d899
This commit is contained in:
parent
401f9d6297
commit
63bd1f6095
2 changed files with 27 additions and 10 deletions
|
@ -612,28 +612,41 @@ module.exports = CompileController = {
|
|||
return pipeline(stream, res)
|
||||
})
|
||||
.then(() => {
|
||||
timer.labels.status = 'success'
|
||||
timer.done()
|
||||
})
|
||||
.catch(err => {
|
||||
const reqAborted = Boolean(req.destroyed)
|
||||
const status = reqAborted ? 'req-aborted-late' : 'error'
|
||||
timer.labels.status = status
|
||||
const duration = timer.done()
|
||||
if (!res.headersSent) {
|
||||
Metrics.inc('proxy_to_clsi', 1, { path: action, status })
|
||||
const streamingStarted = Boolean(res.headersSent)
|
||||
if (!streamingStarted) {
|
||||
if (err instanceof RequestFailedError) {
|
||||
res.sendStatus(err.response.status)
|
||||
} else {
|
||||
res.sendStatus(500)
|
||||
}
|
||||
}
|
||||
const reqAborted = Boolean(req.destroyed)
|
||||
if (reqAborted) {
|
||||
Metrics.inc('proxy_to_clsi', 1, {
|
||||
path: action,
|
||||
status: 'req-aborted-late',
|
||||
})
|
||||
} else {
|
||||
Metrics.inc('proxy_to_clsi', 1, { path: action, status: 'error' })
|
||||
if (
|
||||
streamingStarted &&
|
||||
reqAborted &&
|
||||
err.code === 'ERR_STREAM_PREMATURE_CLOSE'
|
||||
) {
|
||||
// Ignore noisy spurious error
|
||||
return
|
||||
}
|
||||
logger.warn(
|
||||
{ err, projectId, url, action, reqAborted, duration },
|
||||
{
|
||||
err,
|
||||
projectId,
|
||||
url,
|
||||
action,
|
||||
reqAborted,
|
||||
streamingStarted,
|
||||
duration,
|
||||
},
|
||||
'CLSI proxy error'
|
||||
)
|
||||
})
|
||||
|
|
|
@ -81,6 +81,10 @@ describe('CompileController', function () {
|
|||
'@overleaf/metrics': (this.Metrics = {
|
||||
inc: sinon.stub(),
|
||||
Timer: class {
|
||||
constructor() {
|
||||
this.labels = {}
|
||||
}
|
||||
|
||||
done() {}
|
||||
},
|
||||
}),
|
||||
|
|
Loading…
Add table
Reference in a new issue