Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(self-hosted): enable air-gapped use by disabling online check of react query (#2374)

Marc Klingenb6a31f6146dd
diff --git a/packages/shared/prisma/seed.ts b/packages/shared/prisma/seed.ts
index 512081c18c..265adf3271 100644
--- a/packages/shared/prisma/seed.ts
+++ b/packages/shared/prisma/seed.ts
@@ -377,11 +377,10 @@ async function uploadObjects(
});
for (let i = 0; i < promises.length; i++) {
- process.stdout.clearLine(0);
- process.stdout.cursorTo(0);
- process.stdout.write(
- `Seeding of Sessions ${(i / promises.length) * 100}% complete`
- );
+ if (i + 1 >= promises.length || i % Math.ceil(promises.length / 10) === 0)
+ console.log(
+ `Seeding of Sessions ${((i + 1) / promises.length) * 100}% complete`
+ );
await promises[i];
}
@@ -395,11 +394,10 @@ async function uploadObjects(
);
});
for (let i = 0; i < promises.length; i++) {
- process.stdout.clearLine(0);
- process.stdout.cursorTo(0);
- process.stdout.write(
- `Seeding of Traces ${(i / promises.length) * 100}% complete`
- );
+ if (i + 1 >= promises.length || i % Math.ceil(promises.length / 10) === 0)
+ console.log(
+ `Seeding of Traces ${((i + 1) / promises.length) * 100}% complete`
+ );
await promises[i];
}
@@ -413,11 +411,10 @@ async function uploadObjects(
});
for (let i = 0; i < promises.length; i++) {
- process.stdout.clearLine(0);
- process.stdout.cursorTo(0);
- process.stdout.write(
- `Seeding of Observations ${(i / promises.length) * 100}% complete`
- );
+ if (i + 1 >= promises.length || i % Math.ceil(promises.length / 10) === 0)
+ console.log(
+ `Seeding of Observations ${((i + 1) / promises.length) * 100}% complete`
+ );
await promises[i];
}
@@ -431,11 +428,10 @@ async function uploadObjects(
});
for (let i = 0; i < promises.length; i++) {
- process.stdout.clearLine(0);
- process.stdout.cursorTo(0);
- process.stdout.write(
- `Seeding of Events ${(i / promises.length) * 100}% complete`
- );
+ if (i + 1 >= promises.length || i % Math.ceil(promises.length / 10) === 0)
+ console.log(
+ `Seeding of Events ${((i + 1) / promises.length) * 100}% complete`
+ );
await promises[i];
}
@@ -448,11 +444,10 @@ async function uploadObjects(
);
});
for (let i = 0; i < promises.length; i++) {
- process.stdout.clearLine(0);
- process.stdout.cursorTo(0);
- process.stdout.write(
- `Seeding of Scores ${(i / promises.length) * 100}% complete`
- );
+ if (i + 1 >= promises.length || i % Math.ceil(promises.length / 10) === 0)
+ console.log(
+ `Seeding of Scores ${((i + 1) / promises.length) * 100}% complete`
+ );
await promises[i];
}
}
diff --git a/web/src/utils/api.ts b/web/src/utils/api.ts
index d4481b285c..34057e4678 100644
--- a/web/src/utils/api.ts
+++ b/web/src/utils/api.ts
@@ -69,9 +69,21 @@ export const api = createTRPCNext<AppRouter>({
defaultOptions: {
queries: {
onError: (error) => trpcErrorToast(error),
+ // react query defaults to `online`, but we want to disable it in dev and when self-hosting
+ networkMode:
+ process.env.NODE_ENV === "development" ||
+ process.env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION === undefined
+ ? "always"
+ : "online",
},
mutations: {
onError: (error) => trpcErrorToast(error),
+ // react query defaults to `online`, but we want to disable it in dev and when self-hosting
+ networkMode:
+ process.env.NODE_ENV === "development" ||
+ process.env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION === undefined
+ ? "always"
+ : "online",
},
},
},