add error logging on server only

This commit is contained in:
Amruth Pillai
2026-02-08 01:16:38 +01:00
parent 5bdc6de862
commit 0a609306a6
3 changed files with 13 additions and 22 deletions
+1 -12
View File
@@ -11,11 +11,6 @@ import { getLocale } from "@/utils/locale";
export const getORPCClient = createIsomorphicFn()
.server((): RouterClient<typeof router> => {
return createRouterClient(router, {
// interceptors: [
// onError((error) => {
// console.error(error);
// }),
// ],
context: async () => {
const locale = await getLocale();
const reqHeaders = getRequestHeaders();
@@ -30,16 +25,10 @@ export const getORPCClient = createIsomorphicFn()
.client((): RouterClient<typeof router> => {
const link = new RPCLink({
url: `${window.location.origin}/api/rpc`,
plugins: [new BatchLinkPlugin({ groups: [{ condition: () => true, context: {} }] })],
fetch: (request, init) => {
return fetch(request, { ...init, credentials: "include" });
},
// interceptors: [
// onError((error) => {
// if (error instanceof DOMException) return;
// console.error(error);
// }),
// ],
plugins: [new BatchLinkPlugin({ groups: [{ condition: () => true, context: {} }] })],
});
return createORPCClient(link);
+6 -5
View File
@@ -1,6 +1,7 @@
import { SmartCoercionPlugin } from "@orpc/json-schema";
import { OpenAPIGenerator } from "@orpc/openapi";
import { OpenAPIHandler } from "@orpc/openapi/fetch";
import { onError } from "@orpc/server";
import { RequestHeadersPlugin } from "@orpc/server/plugins";
import { ZodToJsonSchemaConverter } from "@orpc/zod/zod4";
import { createFileRoute } from "@tanstack/react-router";
@@ -9,11 +10,11 @@ import { env } from "@/utils/env";
import { getLocale } from "@/utils/locale";
const openAPIHandler = new OpenAPIHandler(router, {
// interceptors: [
// onError((error) => {
// console.error(error);
// }),
// ],
interceptors: [
onError((error) => {
console.error(`ERROR [OpenAPI]: ${error}`);
}),
],
plugins: [
new RequestHeadersPlugin(),
new SmartCoercionPlugin({
+6 -5
View File
@@ -1,3 +1,4 @@
import { onError } from "@orpc/server";
import { RPCHandler } from "@orpc/server/fetch";
import { BatchHandlerPlugin, RequestHeadersPlugin } from "@orpc/server/plugins";
import { createFileRoute } from "@tanstack/react-router";
@@ -5,11 +6,11 @@ import router from "@/integrations/orpc/router";
import { getLocale } from "@/utils/locale";
const rpcHandler = new RPCHandler(router, {
// interceptors: [
// onError((error) => {
// console.error(error);
// }),
// ],
interceptors: [
onError((error) => {
console.error(`ERROR [oRPC]: ${error}`);
}),
],
plugins: [new BatchHandlerPlugin(), new RequestHeadersPlugin()],
});