fix document_missing_exception being thrown to sentry when updating page in elastic

This commit is contained in:
Hongbo Wu 2022-03-28 21:16:33 +08:00
parent 217b9e8835
commit fd18affaec

View file

@ -25,6 +25,7 @@ import {
} from './types'
import { readFileSync } from 'fs'
import { join } from 'path'
import { ResponseError } from '@elastic/elasticsearch/lib/errors'
const INDEX_NAME = 'pages'
const INDEX_ALIAS = 'pages_alias'
@ -210,6 +211,13 @@ export const updatePage = async (
return true
} catch (e) {
if (
e instanceof ResponseError &&
e.message === 'document_missing_exception'
) {
console.info('page has been deleted', id)
return false
}
console.error('failed to update a page in elastic', e)
return false
}