🔊(y-provider) capture convert handler errors in Sentry

The y-provider `/api/convert` handler catches every writer/reader
exception and returns a generic `{"error":"An error occurred"}` 500. The
real JS exception is silently dropped: `logger()` only prints to stdout
when `COLLABORATION_LOGGING=true`, and Sentry's
`setupExpressErrorHandler` only sees unhandled errors — never this one.

Result: Sentry issues `DOCS-4ZY` / `DOCS-4ZZ` / `DOCS-6DK` all fire on
every 500, but none of them carry the underlying JS stack, making
root-cause diagnosis impossible from Python alone.

This patch adds `Sentry.captureException` in the outer catch with
`handler:convert` tag and `contentType` / `accept` / `bodyBytes` extras.
Behavior otherwise unchanged.

Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
This commit is contained in:
Stephan Meijer
2026-07-08 13:51:27 +00:00
committed by GitHub
parent 140334de55
commit 9c9f2134e7
@@ -5,6 +5,7 @@ import {
YjsThreadStore,
} from '@blocknote/core/comments';
import { ServerBlockNoteEditor } from '@blocknote/server-util';
import * as Sentry from '@sentry/node';
import { Request, Response } from 'express';
import * as Y from 'yjs';
@@ -191,6 +192,14 @@ export const convertHandler = async (
.setHeader('content-type', accept)
.send(await writer.write(blocks ?? []));
} catch (e) {
Sentry.captureException(e, {
tags: { handler: 'convert' },
extra: {
contentType,
accept,
bodyBytes: req.body?.length ?? 0,
},
});
logger('conversion failed:', e);
res.status(500).json({ error: 'An error occurred' });
}