fix: Improved websockets error handling (#3726)
* fix: Add websocket client error capturing fix: Incorrect parsing of documentName will never be empty * fix: Non-present documentId in collaboration route should trigger an error response * fix: Close unhandled websocket requests
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { IncomingMessage } from "http";
|
||||
import chalk from "chalk";
|
||||
import { isEmpty } from "lodash";
|
||||
import winston from "winston";
|
||||
@@ -100,8 +101,14 @@ class Logger {
|
||||
* @param message A description of the error
|
||||
* @param error The error that occurred
|
||||
* @param extra Arbitrary data to be logged that will appear in prod logs
|
||||
* @param request An optional request object to attach to the error
|
||||
*/
|
||||
error(message: string, error: Error, extra?: Extra) {
|
||||
error(
|
||||
message: string,
|
||||
error: Error,
|
||||
extra?: Extra,
|
||||
request?: IncomingMessage
|
||||
) {
|
||||
Metrics.increment("logger.error");
|
||||
Tracing.setError(error);
|
||||
|
||||
@@ -113,6 +120,12 @@ class Logger {
|
||||
scope.setExtra(key, extra[key]);
|
||||
}
|
||||
|
||||
if (request) {
|
||||
scope.addEventProcessor(function (event) {
|
||||
return Sentry.Handlers.parseRequest(event, request);
|
||||
});
|
||||
}
|
||||
|
||||
Sentry.captureException(error);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user