Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions envoy/envoy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ static_resources:
prefix: application/grpc
route:
cluster: grpc_backend
timeout: 60s
max_stream_duration:
max_stream_duration: 300s
- match:
prefix: "/"
route:
cluster: http_backend
timeout: 60s
http_filters:
- name: envoy.filters.http.router
typed_config:
Expand Down
12 changes: 10 additions & 2 deletions src/interceptors/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,21 @@ export function authInterceptor<Req, Res>(
}
return handler(call, callback);
})
.catch((error) => callback?.(error));
.catch((error) => {
return callback?.({
code: grpcStatus.UNAVAILABLE,
details: error instanceof Error ? error.message : String(error),
});
});
}

return handler(call, callback);
})
.catch((error) => {
return callback?.(error);
return callback?.({
code: grpcStatus.UNAVAILABLE,
details: error instanceof Error ? error.message : String(error),
});
});
};
}
Expand Down
14 changes: 9 additions & 5 deletions src/interceptors/logging.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { status as grpcStatus } from "@grpc/grpc-js";
import type { sendUnaryData, ServerErrorResponse } from "@grpc/grpc-js";
import type { sendUnaryData } from "@grpc/grpc-js";
import * as Sentry from "@sentry/bun";
import { logger } from "../errors/logger";
import {
Expand Down Expand Up @@ -72,10 +72,10 @@ export function loggingInterceptor(
// Handle async handlers that might throw
if (result && typeof result.then === "function") {
return result.catch((error: unknown) => {
if (!builder["event"].outcome) {
const errorDetails = extractErrorDetails(error);
const statusCode = grpcStatusToHttpStatus(errorDetails.code);
const errorDetails = extractErrorDetails(error);
const statusCode = grpcStatusToHttpStatus(errorDetails.code);

if (!builder["event"].outcome) {
Sentry.captureException(error, {
extra: { requestId, method: url, statusCode },
});
Expand All @@ -89,7 +89,11 @@ export function loggingInterceptor(
const event = builder.build();
logger.emit(event);
}
throw error;

originalCallback?.({
code: errorDetails.code,
details: errorDetails.message,
});
});
Comment thread
greptile-apps[bot] marked this conversation as resolved.
}
};
Expand Down
Loading