mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
[web] catch failed requests to project/doc metadata endpoints (#33139)
Unhandled promise rejections from these fire-and-forget calls were surfacing in Sentry. Add .catch(debugConsole.error) to suppress them. GitOrigin-RevId: a14cd0a3956a2b551210723ad56e7ec5e354a7a7
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import { postJSON } from '../../../infrastructure/fetch-json'
|
||||
import { debugConsole } from '@/utils/debugging'
|
||||
|
||||
export const refreshProjectMetadata = (projectId: string, entityId: string) =>
|
||||
postJSON(`/project/${projectId}/doc/${entityId}/metadata`)
|
||||
postJSON(`/project/${projectId}/doc/${entityId}/metadata`).catch(
|
||||
debugConsole.error
|
||||
)
|
||||
|
||||
@@ -12,6 +12,7 @@ import { useIdeReactContext } from '@/features/ide-react/context/ide-react-conte
|
||||
import { useConnectionContext } from '@/features/ide-react/context/connection-context'
|
||||
import { useEditorOpenDocContext } from '@/features/ide-react/context/editor-open-doc-context'
|
||||
import { getJSON, postJSON } from '@/infrastructure/fetch-json'
|
||||
import { debugConsole } from '@/utils/debugging'
|
||||
import { useOnlineUsersContext } from '@/features/ide-react/context/online-users-context'
|
||||
import useSocketListener from '@/features/ide-react/hooks/use-socket-listener'
|
||||
import useEventListener from '@/shared/hooks/use-event-listener'
|
||||
@@ -92,14 +93,14 @@ export const MetadataProvider: FC<React.PropsWithChildren> = ({ children }) => {
|
||||
}, [])
|
||||
|
||||
const loadProjectMetaFromServer = useCallback(() => {
|
||||
getJSON(`/project/${projectId}/metadata`).then(
|
||||
(response: { projectMeta: DocumentsMetadata }) => {
|
||||
getJSON(`/project/${projectId}/metadata`)
|
||||
.then((response: { projectMeta: DocumentsMetadata }) => {
|
||||
const { projectMeta } = response
|
||||
if (projectMeta) {
|
||||
setDocuments(projectMeta)
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
.catch(debugConsole.error)
|
||||
}, [projectId])
|
||||
|
||||
const loadDocMetaFromServer = useCallback(
|
||||
@@ -111,13 +112,15 @@ export const MetadataProvider: FC<React.PropsWithChildren> = ({ children }) => {
|
||||
body: {
|
||||
broadcast,
|
||||
},
|
||||
}).then((response: DocMetadataResponse) => {
|
||||
if (!broadcast && response) {
|
||||
// handle the POST response like a broadcast event when there are no
|
||||
// other users in the project.
|
||||
onBroadcastDocMeta(response)
|
||||
}
|
||||
})
|
||||
.then((response: DocMetadataResponse) => {
|
||||
if (!broadcast && response) {
|
||||
// handle the POST response like a broadcast event when there are no
|
||||
// other users in the project.
|
||||
onBroadcastDocMeta(response)
|
||||
}
|
||||
})
|
||||
.catch(debugConsole.error)
|
||||
},
|
||||
[onBroadcastDocMeta, onlineUsersCount, projectId]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user