Files
Verso/services/project-history/app/js/HealthChecker.js
T
Jakob AckermannandJessica Lawshe 7c70b749d4 [monorepo] remove PII and variables from error messages (#31508)
* [monorepo] remove PII and variables from error messages

Exclusions:
- scripts
- tests
- fuzzing
- SplitTestManager (messages are sent to admin frontend)
- Group setup (we may want an error per unique tuple)
- sharejs (unused types; text type errors are shadowed already)
- history-v1 error messages that are used by the ErrorRecorder
- errors that flag issues with configuration/call signatures

I've used these search terms for finding unwanted error messages:
- new Error(`
- new Error\(\n\s+` (regex search)
- new OError(`
- new OError\(\n\s+` (regex search)

* [web] throw NotFoundError from ProjectLocator

* [github-sync] fix OError.tag call in script

Co-authored-by: Jessica Lawshe <jessica.lawshe@overleaf.com>

* [templates] revert changes to test client

---------

Co-authored-by: Jessica Lawshe <jessica.lawshe@overleaf.com>
GitOrigin-RevId: 736857a4fc5d9bfb0f8cb03e0f004eda87e5a220
2026-02-17 09:05:04 +00:00

85 lines
2.7 KiB
JavaScript

// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import { ObjectId } from './mongodb.js'
import request from 'request'
import async from 'async'
import settings from '@overleaf/settings'
import logger from '@overleaf/logger'
import OError from '@overleaf/o-error'
import * as LockManager from './LockManager.js'
const { port } = settings.internal.history
export function check(callback) {
const projectId = new ObjectId(settings.history.healthCheck.project_id)
const url = `http://127.0.0.1:${port}/project/${projectId}`
logger.debug({ projectId }, 'running health check')
const jobs = [
cb =>
request.get(
{ url: `http://127.0.0.1:${port}/check_lock`, timeout: 3000 },
function (err, res, body) {
if (err != null) {
OError.tag(err, 'error checking lock for health check', {
project_id: projectId,
})
return cb(err)
} else if ((res != null ? res.statusCode : undefined) !== 200) {
return cb(
new OError('status code not 200', { statusCode: res.statusCode })
)
} else {
return cb()
}
}
),
cb =>
request.post(
{ url: `${url}/flush`, timeout: 10000 },
function (err, res, body) {
if (err != null) {
OError.tag(err, 'error flushing for health check', {
project_id: projectId,
})
return cb(err)
} else if ((res != null ? res.statusCode : undefined) !== 204) {
return cb(
new OError('status code not 204', { statusCode: res.statusCode })
)
} else {
return cb()
}
}
),
cb =>
request.get(
{ url: `${url}/updates`, timeout: 10000 },
function (err, res, body) {
if (err != null) {
OError.tag(err, 'error getting updates for health check', {
project_id: projectId,
})
return cb(err)
} else if ((res != null ? res.statusCode : undefined) !== 200) {
return cb(
new OError('status code not 200', { statusCode: res.statusCode })
)
} else {
return cb()
}
}
),
]
return async.series(jobs, callback)
}
export function checkLock(callback) {
return LockManager.healthCheck(callback)
}