Skip to content

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

refactor: Resolve @repo/no-exotic-operators issues (#18169)

Ben Bachem0ee8fbdd8941
diff --git a/packages/shared/src/db.ts b/packages/shared/src/db.ts
index a2efba2a1b..cd39b4f3c0 100644
--- a/packages/shared/src/db.ts
+++ b/packages/shared/src/db.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
// This file exports the prisma db connection, the Prisma Object, and the Typescript types.
// This is not imported in the index.ts file of this package, as we must not import this into FE code.
@@ -65,7 +64,9 @@ declare const globalThis: {
// eslint-disable-next-line turbo/no-undeclared-env-vars
if (process.env.NODE_ENV === "development") {
- globalThis.prismaGlobal ??= createPrismaInstance(); // regular instantiation
+ if (globalThis.prismaGlobal === undefined) {
+ globalThis.prismaGlobal = createPrismaInstance();
+ }
}
export const prisma =
diff --git a/packages/shared/src/features/monitors/isValidQuery.ts b/packages/shared/src/features/monitors/isValidQuery.ts
index 90b19bc704..75a13f6857 100644
--- a/packages/shared/src/features/monitors/isValidQuery.ts
+++ b/packages/shared/src/features/monitors/isValidQuery.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
/** isValidQuery.ts checks that a Monitor's (view, metric, filters) tuple
* resolves against the v2 view declaration in the query package. Consumed as
* a zod `superRefine` from the Monitor input schemas in `./types`. */
@@ -64,7 +63,9 @@ export function isValidQuery(input: {
const metricReason = invalidMetricReason(declaration, input.view, m);
if (metricReason) {
rejected.push(m);
- reason ??= metricReason;
+ if (reason === undefined) {
+ reason = metricReason;
+ }
} else {
accepted.push(m);
}
diff --git a/packages/shared/src/in-app-agent/server/persistence.ts b/packages/shared/src/in-app-agent/server/persistence.ts
index bf798cb904..07b7887595 100644
--- a/packages/shared/src/in-app-agent/server/persistence.ts
+++ b/packages/shared/src/in-app-agent/server/persistence.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { compactEvents } from "@ag-ui/client";
import { EventType } from "@ag-ui/core";
@@ -1022,7 +1021,9 @@ export function createConversationMessageAccumulator(
};
draft.content += getString(event, "delta") ?? "";
- draft.runId ??= runId;
+ if (draft.runId === undefined) {
+ draft.runId = runId;
+ }
textDrafts.set(messageId, draft);
return upsertMessage({
@@ -1049,7 +1050,9 @@ export function createConversationMessageAccumulator(
if (draft) {
draft.content += delta;
- draft.runId ??= runId;
+ if (draft.runId === undefined) {
+ draft.runId = runId;
+ }
return upsertMessage({
id: draft.id,
role: "assistant",
diff --git a/packages/shared/src/server/llm/errors.ts b/packages/shared/src/server/llm/errors.ts
index 833afda9e9..cad2bf4045 100644
--- a/packages/shared/src/server/llm/errors.ts
+++ b/packages/shared/src/server/llm/errors.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { AISDKError, APICallError, RetryError } from "ai";
const LLM_VALIDATION_ERROR_MARKER = Symbol.for(
@@ -146,7 +145,9 @@ function unwrapRetryError(error: unknown): {
while (RetryError.isInstance(resolvedError) && !visited.has(resolvedError)) {
visited.add(resolvedError);
- retryError ??= resolvedError;
+ if (retryError === undefined) {
+ retryError = resolvedError;
+ }
resolvedError = resolvedError.lastError;
}
diff --git a/packages/shared/src/server/media/MediaPayloadProcessor.ts b/packages/shared/src/server/media/MediaPayloadProcessor.ts
index 866ca4fa37..1bb80edc51 100644
--- a/packages/shared/src/server/media/MediaPayloadProcessor.ts
+++ b/packages/shared/src/server/media/MediaPayloadProcessor.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { isMediaContentType, type MediaContentType } from "../../domain/media";
const MAX_RECURSION_DEPTH = 10;
@@ -282,7 +281,9 @@ function findDataUris(value: string): DataUriOccurrence[] {
const code = value.charCodeAt(headerCursor);
if (code === 44) break;
if (code === 59) {
- contentTypeEnd ??= headerCursor;
+ if (contentTypeEnd === undefined) {
+ contentTypeEnd = headerCursor;
+ }
if (value.startsWith(BASE64_MARKER, headerCursor)) {
markerStart = headerCursor;
break;
diff --git a/packages/shared/src/server/otel/OtelIngestionProcessor.ts b/packages/shared/src/server/otel/OtelIngestionProcessor.ts
index f958ebd618..883cde0b5c 100644
--- a/packages/shared/src/server/otel/OtelIngestionProcessor.ts
+++ b/packages/shared/src/server/otel/OtelIngestionProcessor.ts
@@ -1,5 +1,4 @@
/* eslint-disable no-nested-ternary */
-/* eslint-disable @repo/no-exotic-operators */
import { randomUUID } from "crypto";
import {
@@ -39,6 +38,7 @@ import { env } from "../../env";
import { OtelIngestionQueue } from "../redis/otelIngestionQueue";
import { isValidDateString, flattenJsonToPathArrays } from "./utils";
import { convertDateToClickhouseDateTime } from "../clickhouse/client";
+import { isNullOrUndefined } from "../../utils/isNullOrUndefined";
export const AI_GATEWAY_INSTRUMENTATION_SCOPE_NAME = "langfuse-ai-gateway";
@@ -919,7 +919,7 @@ export class OtelIngestionProcessor {
* Check if a value is meaningful (not null, undefined, empty string, or empty object/array)
*/
private hasMeaningfulValue(value: unknown): boolean {
- if (value === null || value === undefined || value === "") {
+ if (isNullOrUndefined(value) || value === "") {
return false;
}
if (Array.isArray(value)) {
@@ -2015,8 +2015,12 @@ export class OtelIngestionProcessor {
const genAiInputOutput =
this.extractOpenTelemetryGenAiInputAndOutput(attributes);
- input ??= genAiInputOutput?.input;
- output ??= genAiInputOutput?.output;
+ if (isNullOrUndefined(input)) {
+ input = genAiInputOutput?.input;
+ }
+ if (isNullOrUndefined(output)) {
+ output = genAiInputOutput?.output;
+ }
return { input, output, filteredAttributes };
}
@@ -2942,14 +2946,22 @@ export class OtelIngestionProcessor {
if ("openai" in parsed) {
const openaiMetadata = parsed["openai"] as Record<string, number>;
- usageDetails["input_cached_tokens"] ??=
- openaiMetadata["cachedPromptTokens"];
- usageDetails["accepted_prediction_tokens"] ??=
- openaiMetadata["acceptedPredictionTokens"];
- usageDetails["rejected_prediction_tokens"] ??=
- openaiMetadata["rejectedPredictionTokens"];
- usageDetails["output_reasoning_tokens"] ??=
- openaiMetadata["reasoningTokens"];
+ if (isNullOrUndefined(usageDetails["input_cached_tokens"])) {
+ usageDetails["input_cached_tokens"] =
+ openaiMetadata["cachedPromptTokens"];
+ }
+ if (isNullOrUndefined(usageDetails["accepted_prediction_tokens"])) {
+ usageDetails["accepted_prediction_tokens"] =
+ openaiMetadata["acceptedPredictionTokens"];
+ }
+ if (isNullOrUndefined(usageDetails["rejected_prediction_tokens"])) {
+ usageDetails["rejected_prediction_tokens"] =
+ openaiMetadata["rejectedPredictionTokens"];
+ }
+ if (isNullOrUndefined(usageDetails["output_reasoning_tokens"])) {
+ usageDetails["output_reasoning_tokens"] =
+ openaiMetadata["reasoningTokens"];
+ }
}
// "ai.response.providerMetadata": {"anthropic":{"usage":{"input_tokens":7,"cache_creation_input_tokens":2089,"cache_read_input_tokens":16399,"cache_creation":{"ephemeral_5m_input_tokens":2089,"ephemeral_1h_input_tokens":0},"output_tokens":445,"service_tier":"standard"},"cacheCreationInputTokens":2089,"stopSequence":null,"container":null,"contextManagement":null}}
@@ -2959,12 +2971,16 @@ export class OtelIngestionProcessor {
unknown
>;
- usageDetails["input_cache_creation"] ??= (
- anthropicMetadata as Record<string, number>
- )["cache_creation_input_tokens"];
- usageDetails["input_cached_tokens"] ??= (
- anthropicMetadata as Record<string, number>
- )["cache_read_input_tokens"];
+ if (isNullOrUndefined(usageDetails["input_cache_creation"])) {
+ usageDetails["input_cache_creation"] = (
+ anthropicMetadata as Record<string, number>
+ )["cache_creation_input_tokens"];
+ }
+ if (isNullOrUndefined(usageDetails["input_cached_tokens"])) {
+ usageDetails["input_cached_tokens"] = (
+ anthropicMetadata as Record<string, number>
+ )["cache_read_input_tokens"];
+ }
// Extract cache creation duration breakdown (5m and 1h TTLs)
if (
@@ -2978,14 +2994,22 @@ export class OtelIngestionProcessor {
if (
typeof cacheCreation["ephemeral_5m_input_tokens"] === "number"
) {
- usageDetails["input_cache_creation_5m"] ??=
- cacheCreation["ephemeral_5m_input_tokens"];
+ if (
+ isNullOrUndefined(usageDetails["input_cache_creation_5m"])
+ ) {
+ usageDetails["input_cache_creation_5m"] =
+ cacheCreation["ephemeral_5m_input_tokens"];
+ }
}
if (
typeof cacheCreation["ephemeral_1h_input_tokens"] === "number"
) {
- usageDetails["input_cache_creation_1h"] ??=
- cacheCreation["ephemeral_1h_input_tokens"];
+ if (
+ isNullOrUndefined(usageDetails["input_cache_creation_1h"])
+ ) {
+ usageDetails["input_cache_creation_1h"] =
+ cacheCreation["ephemeral_1h_input_tokens"];
+ }
}
// Subtract duration-specific counts from total to avoid double counting
@@ -3007,16 +3031,22 @@ export class OtelIngestionProcessor {
const usage = bedrockMetadata["usage"] as Record<string, number>;
if (usage["cacheReadInputTokens"] !== undefined) {
- usageDetails["input_cache_read"] ??=
- usage["cacheReadInputTokens"];
+ if (isNullOrUndefined(usageDetails["input_cache_read"])) {
+ usageDetails["input_cache_read"] =
+ usage["cacheReadInputTokens"];
+ }
}
if (usage["cacheWriteInputTokens"] !== undefined) {
- usageDetails["input_cache_write"] ??=
- usage["cacheWriteInputTokens"];
+ if (isNullOrUndefined(usageDetails["input_cache_write"])) {
+ usageDetails["input_cache_write"] =
+ usage["cacheWriteInputTokens"];
+ }
}
if (usage["cacheCreationInputTokens"] !== undefined) {
- usageDetails["input_cache_creation"] ??=
- usage["cacheCreationInputTokens"];
+ if (isNullOrUndefined(usageDetails["input_cache_creation"])) {
+ usageDetails["input_cache_creation"] =
+ usage["cacheCreationInputTokens"];
+ }
}
}
}
@@ -3304,7 +3334,7 @@ export class OtelIngestionProcessor {
attributes["ai.telemetry.metadata.tags"] ||
attributes["tag.tags"];
- if (tagsValue === undefined || tagsValue === null) {
+ if (isNullOrUndefined(tagsValue)) {
return [];
}
@@ -3402,7 +3432,7 @@ export class OtelIngestionProcessor {
value: unknown,
context: MetadataDropContext,
): Record<string, unknown> {
- if (value === undefined || value === null) {
+ if (isNullOrUndefined(value)) {
return {};
}
@@ -3780,11 +3810,14 @@ export class OtelIngestionProcessor {
return undefined;
}
- // Convert high and low to BigInt
+ // Preserve protobuf Long's signed high word and unsigned low word.
+ // eslint-disable-next-line @repo/no-exotic-operators
const highBits = BigInt(timestamp.high) << BigInt(32);
+ // eslint-disable-next-line @repo/no-exotic-operators
const lowBits = BigInt(timestamp.low >>> 0);
// Combine high and low bits
+ // eslint-disable-next-line @repo/no-exotic-operators
const nanosBigInt = highBits | lowBits;
// Convert nanoseconds to milliseconds for JavaScript Date
diff --git a/packages/shared/src/server/query-ast/dialect.ts b/packages/shared/src/server/query-ast/dialect.ts
index f6d7f83742..c429840793 100644
--- a/packages/shared/src/server/query-ast/dialect.ts
+++ b/packages/shared/src/server/query-ast/dialect.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import {
DummyDriver,
Kysely,
@@ -36,8 +35,10 @@ export class ClickHouseCompileDialect implements Dialect {
let compileDb: Kysely<ClickHouseDatabase> | undefined;
export function getClickhouseKysely(): Kysely<ClickHouseDatabase> {
- compileDb ??= new Kysely<ClickHouseDatabase>({
- dialect: new ClickHouseCompileDialect(),
- });
+ if (compileDb === undefined) {
+ compileDb = new Kysely<ClickHouseDatabase>({
+ dialect: new ClickHouseCompileDialect(),
+ });
+ }
return compileDb;
}
diff --git a/packages/shared/src/server/repositories/experimentScoreOptions.ts b/packages/shared/src/server/repositories/experimentScoreOptions.ts
index 02750bd4a9..c64d777a3b 100644
--- a/packages/shared/src/server/repositories/experimentScoreOptions.ts
+++ b/packages/shared/src/server/repositories/experimentScoreOptions.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
/**
* The level-agnostic score-option shape shared by the experiment runs and items
* surfaces. Kept free of query imports so it stays a pure, directly testable
@@ -58,9 +57,18 @@ export const toAgnosticScoreFilterOptions = (
pick: (options: ProcessedScoreFilterOptions) => string[],
): ScoreNameLevels => {
const out: ScoreNameLevels = {};
- for (const name of pick(observation))
- (out[name] ??= []).push("observation");
- for (const name of pick(trace)) (out[name] ??= []).push("trace");
+ for (const name of pick(observation)) {
+ if (out[name] === undefined) {
+ out[name] = [];
+ }
+ out[name].push("observation");
+ }
+ for (const name of pick(trace)) {
+ if (out[name] === undefined) {
+ out[name] = [];
+ }
+ out[name].push("trace");
+ }
return out;
};
diff --git a/packages/shared/src/server/services/PromptService/index.ts b/packages/shared/src/server/services/PromptService/index.ts
index cf71a64997..41435b4fa2 100644
--- a/packages/shared/src/server/services/PromptService/index.ts
+++ b/packages/shared/src/server/services/PromptService/index.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { Redis, Cluster } from "ioredis";
import { randomBytes } from "crypto";
import { env } from "../../../env";
@@ -349,7 +348,9 @@ export class PromptService {
);
// side-effect: populate adjacency list to return later as well
- graph.dependencies[currentPrompt.id] ??= []; // initializes an empty list if it does not exist yet
+ if (graph.dependencies[currentPrompt.id] === undefined) {
+ graph.dependencies[currentPrompt.id] = [];
+ }
graph.dependencies[currentPrompt.id].push({
id: depPrompt.id,
name: depPrompt.name,
diff --git a/packages/shared/src/server/services/safeBlobKeySegment.ts b/packages/shared/src/server/services/safeBlobKeySegment.ts
index f96fe736e6..8ca5d64aa2 100644
--- a/packages/shared/src/server/services/safeBlobKeySegment.ts
+++ b/packages/shared/src/server/services/safeBlobKeySegment.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { createHash } from "crypto";
import { env } from "../../env";
@@ -21,7 +20,7 @@ function sliceUtf8Bytes(input: string, maxBytes: number): string {
// truncate inside a multi-byte sequence.
let end = maxBytes;
// skip continuation bytes (0x80–0xBF)
- while (end > 0 && (buf[end] & 0xc0) === 0x80) end--;
+ while (end > 0 && buf[end] >= 0x80 && buf[end] <= 0xbf) end--;
return buf.subarray(0, end).toString("utf8");
}
diff --git a/packages/shared/src/utils/isNullOrUndefined.test.ts b/packages/shared/src/utils/isNullOrUndefined.test.ts
new file mode 100644
index 0000000000..f4e8f7c926
--- /dev/null
+++ b/packages/shared/src/utils/isNullOrUndefined.test.ts
@@ -0,0 +1,15 @@
+import { describe, expect, it } from "vitest";
+import { isNullOrUndefined } from "./isNullOrUndefined";
+
+describe("isNullOrUndefined", () => {
+ it.each([null, undefined])("matches %s", (value) => {
+ expect(isNullOrUndefined(value)).toBe(true);
+ });
+
+ it.each([0, false, "", NaN, [], {}])(
+ "preserves non-nullish values: %s",
+ (value) => {
+ expect(isNullOrUndefined(value)).toBe(false);
+ },
+ );
+});
diff --git a/packages/shared/src/utils/isNullOrUndefined.ts b/packages/shared/src/utils/isNullOrUndefined.ts
new file mode 100644
index 0000000000..98fc47369d
--- /dev/null
+++ b/packages/shared/src/utils/isNullOrUndefined.ts
@@ -0,0 +1,3 @@
+export function isNullOrUndefined(value: unknown) {
+ return value === null || value === undefined;
+}
diff --git a/web/src/__tests__/chart-loading-state.clienttest.tsx b/web/src/__tests__/chart-loading-state.clienttest.tsx
index b32c02c583..9987890085 100644
--- a/web/src/__tests__/chart-loading-state.clienttest.tsx
+++ b/web/src/__tests__/chart-loading-state.clienttest.tsx
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import React from "react";
import { act, fireEvent, render, screen } from "@testing-library/react";
import { SLOW_QUERY_HINT_TEXT } from "@langfuse/shared";
@@ -197,6 +196,7 @@ describe("ChartLoadingState", () => {
const hint = screen.getByText(SLOW_QUERY_HINT_TEXT);
expect(
+ // eslint-disable-next-line @repo/no-exotic-operators
progressText.compareDocumentPosition(hint) &
Node.DOCUMENT_POSITION_FOLLOWING,
).toBeTruthy();
diff --git a/web/src/__tests__/server/media.servertest.ts b/web/src/__tests__/server/media.servertest.ts
index c6597b002e..1974bc48b1 100644
--- a/web/src/__tests__/server/media.servertest.ts
+++ b/web/src/__tests__/server/media.servertest.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { testFeatureFlags } from "@/src/__tests__/fixtures/feature-flags";
import crypto from "crypto";
import fs from "fs";
@@ -944,7 +943,7 @@ describe("Media Upload API", () => {
// Create a modified copy of the PNG file bytes by changing a single byte
const modifiedFileBytes = Buffer.from(validPNG.fileBytes);
- modifiedFileBytes[0] = modifiedFileBytes[0] ^ 0xff; // Flip bits of first byte
+ modifiedFileBytes[0] = 255 - modifiedFileBytes[0];
const result = await runMediaUploadEndToEndTest({
...validPNG,
diff --git a/web/src/__tests__/server/prompts.v2.servertest.ts b/web/src/__tests__/server/prompts.v2.servertest.ts
index e520605fd9..06389b59dd 100644
--- a/web/src/__tests__/server/prompts.v2.servertest.ts
+++ b/web/src/__tests__/server/prompts.v2.servertest.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { prisma, Role } from "@langfuse/shared/src/db";
import { disconnectQueues, makeAPICall } from "@/src/__tests__/test-utils";
import type { NextApiRequest, NextApiResponse } from "next";
@@ -309,7 +308,7 @@ describe("/api/public/v2/prompts API Endpoint", () => {
testPromptEquality(createPromptParams, fetchedPrompt.body);
});
- (it("should fetch the latest prompt if label is latest", async () => {
+ it("should fetch the latest prompt if label is latest", async () => {
const { projectId, auth } = await createOrgProjectAndApiKey();
const promptName = "latestPrompt_" + nanoid();
@@ -367,51 +366,51 @@ describe("/api/public/v2/prompts API Endpoint", () => {
}
testPromptEquality(productionPromptParams, fetchedDefaultPrompt.body);
- }),
- it("should fetch the production prompt if no version or label set", async () => {
- const { projectId, auth } = await createOrgProjectAndApiKey();
- const promptName = "prompt_" + nanoid();
+ });
+ it("should fetch the production prompt if no version or label set", async () => {
+ const { projectId, auth } = await createOrgProjectAndApiKey();
+ const promptName = "prompt_" + nanoid();
- const nonProductionPromptParams: CreatePromptInDBParams = {
- name: promptName,
- prompt: "prompt",
- labels: ["staging"],
- version: 1,
- config: {
- temperature: 0.1,
- },
- projectId,
- createdBy: "user-1",
- };
+ const nonProductionPromptParams: CreatePromptInDBParams = {
+ name: promptName,
+ prompt: "prompt",
+ labels: ["staging"],
+ version: 1,
+ config: {
+ temperature: 0.1,
+ },
+ projectId,
+ createdBy: "user-1",
+ };
- const productionPromptParams: CreatePromptInDBParams = {
- name: promptName,
- prompt: "prompt",
- labels: ["production"],
- version: 2,
- config: {
- temperature: 0.1,
- },
- projectId,
- createdBy: "user-1",
- };
+ const productionPromptParams: CreatePromptInDBParams = {
+ name: promptName,
+ prompt: "prompt",
+ labels: ["production"],
+ version: 2,
+ config: {
+ temperature: 0.1,
+ },
+ projectId,
+ createdBy: "user-1",
+ };
- await createPromptInDB(productionPromptParams);
- await createPromptInDB(nonProductionPromptParams);
+ await createPromptInDB(productionPromptParams);
+ await createPromptInDB(nonProductionPromptParams);
- const fetchedPrompt = await makeAPICall<Prompt>(
- "GET",
- `${baseURI}/${encodeURIComponent(promptName)}`,
- undefined,
- auth,
- );
+ const fetchedPrompt = await makeAPICall<Prompt>(
+ "GET",
+ `${baseURI}/${encodeURIComponent(promptName)}`,
+ undefined,
+ auth,
+ );
- if (!isPrompt(fetchedPrompt.body)) {
- throw new Error("Expected body to be a prompt");
- }
+ if (!isPrompt(fetchedPrompt.body)) {
+ throw new Error("Expected body to be a prompt");
+ }
- testPromptEquality(productionPromptParams, fetchedPrompt.body);
- }));
+ testPromptEquality(productionPromptParams, fetchedPrompt.body);
+ });
it("should return a 404 if prompt does not exist", async () => {
const fetchedPrompt = await makeAPICall<Prompt>(
diff --git a/web/src/components/editor/autoScrollOnSelectionDrag.ts b/web/src/components/editor/autoScrollOnSelectionDrag.ts
index edb30e2b4e..78d6c7d3ae 100644
--- a/web/src/components/editor/autoScrollOnSelectionDrag.ts
+++ b/web/src/components/editor/autoScrollOnSelectionDrag.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { type EditorView, ViewPlugin } from "@uiw/react-codemirror";
import { type Extension } from "@codemirror/state";
@@ -157,7 +156,7 @@ class AutoScrollOnSelectionDrag {
// off-window); stop once the primary button is released. Only the primary
// bit matters — a secondary/middle button held or released mid-drag must
// not end the gesture.
- if ((e.buttons & 1) === 0) {
+ if (e.buttons % 2 === 0) {
stop();
return;
}
diff --git a/web/src/components/table/data-table-controls.clienttest.tsx b/web/src/components/table/data-table-controls.clienttest.tsx
index 2426c61b37..873dab18f6 100644
--- a/web/src/components/table/data-table-controls.clienttest.tsx
+++ b/web/src/components/table/data-table-controls.clienttest.tsx
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { act, fireEvent, render, screen } from "@testing-library/react";
import * as AccordionPrimitive from "@radix-ui/react-accordion";
import { eventsTableCols, type FilterState } from "@langfuse/shared";
@@ -368,6 +367,7 @@ describe("CategoricalFacet", () => {
const label = screen.getByText("gpt-4.1");
const suffix = screen.getByText("Project default");
expect(
+ // eslint-disable-next-line @repo/no-exotic-operators
label.compareDocumentPosition(suffix) & Node.DOCUMENT_POSITION_FOLLOWING,
).toBeTruthy();
expect(label).not.toHaveClass("flex-1");
@@ -461,6 +461,7 @@ describe("CategoricalFacet", () => {
const firstUnselected = screen.getByText("opt-0");
expect(selected).toBeInTheDocument();
expect(
+ // eslint-disable-next-line @repo/no-exotic-operators
selected.compareDocumentPosition(firstUnselected) &
Node.DOCUMENT_POSITION_FOLLOWING,
).toBeTruthy();
@@ -617,6 +618,7 @@ describe("CategoricalFacet", () => {
const firstKept = screen.getByText("opt-0");
expect(excluded).toBeInTheDocument();
expect(
+ // eslint-disable-next-line @repo/no-exotic-operators
excluded.compareDocumentPosition(firstKept) &
Node.DOCUMENT_POSITION_FOLLOWING,
).toBeTruthy();
@@ -700,6 +702,7 @@ describe("CategoricalFacet", () => {
const a = screen.getByText("a");
const c = screen.getByText("c");
expect(
+ // eslint-disable-next-line @repo/no-exotic-operators
a.compareDocumentPosition(c) & Node.DOCUMENT_POSITION_FOLLOWING,
).toBeTruthy();
});
@@ -742,6 +745,7 @@ describe("DataTableControls facet ordering", () => {
const a = screen.getByText(first);
const b = screen.getByText(second);
return Boolean(
+ // eslint-disable-next-line @repo/no-exotic-operators
a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING,
);
};
@@ -1383,6 +1387,7 @@ describe("DataTableControls facet-name search", () => {
const a = screen.getByText(first);
const b = screen.getByText(second);
return Boolean(
+ // eslint-disable-next-line @repo/no-exotic-operators
a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING,
);
};
diff --git a/web/src/ee/features/billing/server/chb/chbProjectEvents.ts b/web/src/ee/features/billing/server/chb/chbProjectEvents.ts
index 05fa702bd1..dd38cad442 100644
--- a/web/src/ee/features/billing/server/chb/chbProjectEvents.ts
+++ b/web/src/ee/features/billing/server/chb/chbProjectEvents.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import {
EventBridgeClient,
PutEventsCommand,
@@ -97,13 +96,15 @@ const buildChbProjectEventPayload = (params: {
let cachedClient: EventBridgeClient | undefined;
const getEventBridgeClient = (region: string): EventBridgeClient => {
- cachedClient ??= new EventBridgeClient({
- region,
- requestHandler: {
- requestTimeout: EVENT_BUS_REQUEST_TIMEOUT_MS,
- throwOnRequestTimeout: true,
- },
- });
+ if (cachedClient === undefined) {
+ cachedClient = new EventBridgeClient({
+ region,
+ requestHandler: {
+ requestTimeout: EVENT_BUS_REQUEST_TIMEOUT_MS,
+ throwOnRequestTimeout: true,
+ },
+ });
+ }
return cachedClient;
};
diff --git a/web/src/features/evals/utils/code-eval-template-validation.ts b/web/src/features/evals/utils/code-eval-template-validation.ts
index 58eeff50ed..88c273a7e0 100644
--- a/web/src/features/evals/utils/code-eval-template-validation.ts
+++ b/web/src/features/evals/utils/code-eval-template-validation.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import type * as ts from "@typescript/typescript6";
import type { Diagnostic as RuffDiagnostic } from "@astral-sh/ruff-wasm-web";
import {
@@ -937,9 +936,11 @@ function hasEvaluateFunction(
if (tsModule.isExportDeclaration(node) && !node.moduleSpecifier) {
const exportClause = node.exportClause;
if (exportClause && tsModule.isNamedExports(exportClause)) {
- hasEvaluate ||= exportClause.elements.some(
- (element) => element.name.text === "evaluate",
- );
+ if (!hasEvaluate) {
+ hasEvaluate = exportClause.elements.some(
+ (element) => element.name.text === "evaluate",
+ );
+ }
}
}
@@ -1037,15 +1038,17 @@ function collectPythonContractDiagnostics(
}
async function getPythonRuffWorkspace(): Promise<RuffWorkspace> {
- ruffWorkspacePromise ??= import("@astral-sh/ruff-wasm-web").then(
- async (ruffModule) => {
- await ruffModule.default();
- return new ruffModule.Workspace(
- PYTHON_RUFF_SETTINGS,
- ruffModule.PositionEncoding.Utf16,
- ) as RuffWorkspace;
- },
- );
+ if (ruffWorkspacePromise === null) {
+ ruffWorkspacePromise = import("@astral-sh/ruff-wasm-web").then(
+ async (ruffModule) => {
+ await ruffModule.default();
+ return new ruffModule.Workspace(
+ PYTHON_RUFF_SETTINGS,
+ ruffModule.PositionEncoding.Utf16,
+ ) as RuffWorkspace;
+ },
+ );
+ }
return ruffWorkspacePromise;
}
diff --git a/web/src/features/events/hooks/useEventsFilterOptions.ts b/web/src/features/events/hooks/useEventsFilterOptions.ts
index 4ad8b464b5..6fa9766b5a 100644
--- a/web/src/features/events/hooks/useEventsFilterOptions.ts
+++ b/web/src/features/events/hooks/useEventsFilterOptions.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { api, type RouterInputs, type RouterOutputs } from "@/src/utils/api";
import { useCallback, useMemo, useState } from "react";
import { type FilterState, type TimeFilter } from "@langfuse/shared";
@@ -208,7 +207,9 @@ export function useEventsFilterOptions({
!EAGER_COLUMN_SET.has(col) &&
!prev.has(col)
) {
- next ??= new Set(prev);
+ if (next === null) {
+ next = new Set(prev);
+ }
next.add(col);
}
}
diff --git a/web/src/features/events/server/eventsService.ts b/web/src/features/events/server/eventsService.ts
index 7d0141f62e..d5dd3afa4d 100644
--- a/web/src/features/events/server/eventsService.ts
+++ b/web/src/features/events/server/eventsService.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { type z } from "zod";
import {
type FilterCondition,
@@ -845,7 +844,10 @@ export async function getEventFilterOptions(
}
return "categorical";
})(); // CATEGORICAL + TEXT
- const levels = (scoreNameLevelsByType[typeClass][score.name] ??= []);
+ if (scoreNameLevelsByType[typeClass][score.name] === undefined) {
+ scoreNameLevelsByType[typeClass][score.name] = [];
+ }
+ const levels = scoreNameLevelsByType[typeClass][score.name];
if (!levels.includes(level)) levels.push(level);
};
observationLevelScoreNames.forEach((score) =>
diff --git a/web/src/features/experiments/server/router.ts b/web/src/features/experiments/server/router.ts
index 3095e93089..b2260d9044 100644
--- a/web/src/features/experiments/server/router.ts
+++ b/web/src/features/experiments/server/router.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { z } from "zod/v4";
import { randomUUID } from "crypto";
import { addDays } from "date-fns";
@@ -583,9 +582,18 @@ export const experimentsRouter = createTRPCRouter({
traceNames: string[],
): Record<string, ("observation" | "trace")[]> => {
const out: Record<string, ("observation" | "trace")[]> = {};
- for (const name of observationNames)
- (out[name] ??= []).push("observation");
- for (const name of traceNames) (out[name] ??= []).push("trace");
+ for (const name of observationNames) {
+ if (out[name] === undefined) {
+ out[name] = [];
+ }
+ out[name].push("observation");
+ }
+ for (const name of traceNames) {
+ if (out[name] === undefined) {
+ out[name] = [];
+ }
+ out[name].push("trace");
+ }
return out;
};
diff --git a/web/src/features/in-app-agent/components/utils/utils.ts b/web/src/features/in-app-agent/components/utils/utils.ts
index 82e60b9630..d2914bb55b 100644
--- a/web/src/features/in-app-agent/components/utils/utils.ts
+++ b/web/src/features/in-app-agent/components/utils/utils.ts
@@ -1,5 +1,4 @@
/* eslint-disable no-nested-ternary */
-/* eslint-disable @repo/no-exotic-operators */
import { z } from "zod";
import type { InAppAgentWindowMessage } from "../InAppAgentWindow";
import type { InAppAgentPendingToolApproval } from "../InAppAiAgentProvider";
@@ -625,7 +624,9 @@ export function getDrawerMessages({
pendingSources = mergeSources(pendingSources, docsSources);
}
- pendingToolGroupId ??= `tools-${message.id}`;
+ if (pendingToolGroupId === null) {
+ pendingToolGroupId = `tools-${message.id}`;
+ }
pendingTools.push(...toolContent);
return;
}
diff --git a/web/src/features/posthog-analytics/server/backendActivity.ts b/web/src/features/posthog-analytics/server/backendActivity.ts
index 96aa2e1bff..14f15ce5ab 100644
--- a/web/src/features/posthog-analytics/server/backendActivity.ts
+++ b/web/src/features/posthog-analytics/server/backendActivity.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { logger, redis } from "@langfuse/shared/src/server";
import { env } from "@/src/env.mjs";
@@ -95,7 +94,9 @@ let serverPosthog: ServerPosthog | undefined;
export const recordBackendActivity = createBackendActivityTracker({
capture: (event) => {
- serverPosthog ??= new ServerPosthog();
+ if (serverPosthog === undefined) {
+ serverPosthog = new ServerPosthog();
+ }
serverPosthog.capture(event);
},
cloudRegion:
diff --git a/web/src/features/search-bar/lib/validate.ts b/web/src/features/search-bar/lib/validate.ts
index 28094b098a..a77ee14486 100644
--- a/web/src/features/search-bar/lib/validate.ts
+++ b/web/src/features/search-bar/lib/validate.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
// Semantic validation — the single "is this committable" gate.
//
// The tolerant parser accepts structurally-fine input that the flat Langfuse
@@ -241,7 +240,9 @@ export function semanticDiagnostics(
termRegistry,
);
if (isCompatibilityScope && searchType !== null) {
- firstCompatibilityScope ??= node;
+ if (firstCompatibilityScope === undefined) {
+ firstCompatibilityScope = node;
+ }
}
const span = nodeSpan(node, textLength);
for (const message of errors) {
diff --git a/web/src/features/sessions/SessionMetadataJsonPathControl.tsx b/web/src/features/sessions/SessionMetadataJsonPathControl.tsx
index fd9c378321..83cec5c8f4 100644
--- a/web/src/features/sessions/SessionMetadataJsonPathControl.tsx
+++ b/web/src/features/sessions/SessionMetadataJsonPathControl.tsx
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { type FilterState } from "@langfuse/shared";
import {
hashKey,
@@ -96,13 +95,21 @@ const getFirstCachedObservation = ({
queryHashes.forEach((queryHash, index) => {
const queryState = queryCache.get(queryHash)?.state;
const response = queryState?.data as ObservationResponse | undefined;
- hasResolvedQuery ||= response !== undefined;
- isFetching ||= queryState?.fetchStatus === "fetching";
- isError ||= queryState?.status === "error";
- firstObservation ??= getVisibleSessionObservations(
- response,
- traceIds[index] ?? "",
- ).visibleObservations?.[0];
+ if (response !== undefined) {
+ hasResolvedQuery = true;
+ }
+ if (queryState?.fetchStatus === "fetching") {
+ isFetching = true;
+ }
+ if (queryState?.status === "error") {
+ isError = true;
+ }
+ if (firstObservation === undefined) {
+ firstObservation = getVisibleSessionObservations(
+ response,
+ traceIds[index] ?? "",
+ ).visibleObservations?.[0];
+ }
});
return { firstObservation, hasResolvedQuery, isFetching, isError };
diff --git a/web/src/features/traces/components/AdvancedJsonViewer/lazy/byteJsonIndex.ts b/web/src/features/traces/components/AdvancedJsonViewer/lazy/byteJsonIndex.ts
index aac02dc771..d2e676147e 100644
--- a/web/src/features/traces/components/AdvancedJsonViewer/lazy/byteJsonIndex.ts
+++ b/web/src/features/traces/components/AdvancedJsonViewer/lazy/byteJsonIndex.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
/**
* Lazy UTF-8 JSON byte indexer (LFE-11082, spike LFE-11079).
*
@@ -729,7 +728,8 @@ export class ByteJsonIndexEngine {
if (sliceEnd < node.valueEnd) {
while (
sliceEnd > node.valueStart &&
- (this.bytes[sliceEnd]! & 0xc0) === 0x80
+ this.bytes[sliceEnd]! >= 0x80 &&
+ this.bytes[sliceEnd]! <= 0xbf
) {
sliceEnd--;
}
diff --git a/web/src/features/web-callouts/server/rateLimit.ts b/web/src/features/web-callouts/server/rateLimit.ts
index 2b9737d3cf..c3c4b2150d 100644
--- a/web/src/features/web-callouts/server/rateLimit.ts
+++ b/web/src/features/web-callouts/server/rateLimit.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { TRPCError } from "@trpc/server";
import { RateLimiterRedis, RateLimiterRes } from "rate-limiter-flexible";
import { type Cluster, type Redis } from "ioredis";
@@ -172,9 +171,11 @@ export class WebCalloutRateLimitService {
return;
}
- this.redisConnectPromise ??= redis.connect().finally(() => {
- this.redisConnectPromise = null;
- });
+ if (this.redisConnectPromise === null) {
+ this.redisConnectPromise = redis.connect().finally(() => {
+ this.redisConnectPromise = null;
+ });
+ }
await this.redisConnectPromise;
}
diff --git a/web/src/hooks/useAnimatedBusy.ts b/web/src/hooks/useAnimatedBusy.ts
index dea2243bf6..ee3ac68c5c 100644
--- a/web/src/hooks/useAnimatedBusy.ts
+++ b/web/src/hooks/useAnimatedBusy.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { useEffect, useRef, useState } from "react";
export type AnimatedBusy = {
@@ -34,7 +33,9 @@ export function useAnimatedBusy(
useEffect(() => {
if (busy) {
- startedAt.current ??= Date.now();
+ if (startedAt.current === null) {
+ startedAt.current = Date.now();
+ }
setState((prev) =>
prev.active ? prev : { active: true, epoch: prev.epoch + 1 },
);
diff --git a/web/src/pages/project/~/[[...path]].tsx b/web/src/pages/project/~/[[...path]].tsx
index a4006aa97d..28f00eb430 100644
--- a/web/src/pages/project/~/[[...path]].tsx
+++ b/web/src/pages/project/~/[[...path]].tsx
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import {
type GetServerSideProps,
type GetServerSidePropsContext,
@@ -39,8 +38,12 @@ const parseSentinelRequest = (
cookie: readProjectCookie(ctx.req.cookies ?? {}),
origin: getRequestOrigin(ctx.req),
resolvedUrl: ctx.resolvedUrl,
- getSession: () =>
- (session ??= getServerAuthSession({ req: ctx.req, res: ctx.res })),
+ getSession: () => {
+ if (session === undefined) {
+ session = getServerAuthSession({ req: ctx.req, res: ctx.res });
+ }
+ return session;
+ },
};
};
diff --git a/worker/src/__tests__/batchDataRetentionCleaner.test.ts b/worker/src/__tests__/batchDataRetentionCleaner.test.ts
index e7502cb977..4f45cfa98c 100644
--- a/worker/src/__tests__/batchDataRetentionCleaner.test.ts
+++ b/worker/src/__tests__/batchDataRetentionCleaner.test.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { afterEach, beforeEach, expect, describe, it, vi } from "vitest";
import { randomUUID } from "crypto";
import {
@@ -656,7 +655,9 @@ describe("BatchDataRetentionCleaner", () => {
const extend = vi.fn(async () => {
const isCandidateStreamActive =
integrationHooks.activeCandidateStreams > 0;
- extendedDuringCandidateStream ||= isCandidateStreamActive;
+ if (isCandidateStreamActive) {
+ extendedDuringCandidateStream = true;
+ }
return isCandidateStreamActive;
});
(
diff --git a/worker/src/features/evaluation/codeBased/awsLambdaCodeEvalDispatcher.integration.test.ts b/worker/src/features/evaluation/codeBased/awsLambdaCodeEvalDispatcher.integration.test.ts
index bd5d18c652..02b819999d 100644
--- a/worker/src/features/evaluation/codeBased/awsLambdaCodeEvalDispatcher.integration.test.ts
+++ b/worker/src/features/evaluation/codeBased/awsLambdaCodeEvalDispatcher.integration.test.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { describe, expect, it } from "vitest";
import {
AwsLambdaCodeEvalDispatcher,
@@ -11,9 +10,15 @@ const endpoint = process.env.LANGFUSE_CODE_EVAL_AWS_LAMBDA_ENDPOINT;
const describeWithFloci = endpoint ? describe : describe.skip;
const FLOCI_TEST_TIMEOUT_MS = 30_000;
-process.env.AWS_ACCESS_KEY_ID ??= "test";
-process.env.AWS_SECRET_ACCESS_KEY ??= "test";
-process.env.AWS_REGION ??= "us-east-1";
+if (process.env.AWS_ACCESS_KEY_ID === undefined) {
+ process.env.AWS_ACCESS_KEY_ID = "test";
+}
+if (process.env.AWS_SECRET_ACCESS_KEY === undefined) {
+ process.env.AWS_SECRET_ACCESS_KEY = "test";
+}
+if (process.env.AWS_REGION === undefined) {
+ process.env.AWS_REGION = "us-east-1";
+}
const baseInput: DispatchInput = {
scope: {
diff --git a/worker/src/features/in-app-agent/executeInAppAgentRun.test.ts b/worker/src/features/in-app-agent/executeInAppAgentRun.test.ts
index 17503869e7..c1907f5d2a 100644
--- a/worker/src/features/in-app-agent/executeInAppAgentRun.test.ts
+++ b/worker/src/features/in-app-agent/executeInAppAgentRun.test.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { randomUUID } from "crypto";
import { beforeEach, describe, expect, it, vi } from "vitest";
@@ -18,11 +17,21 @@ vi.hoisted(() => {
// provider. Keep its provider selection explicit rather than inheriting the
// developer's root .env.
delete process.env.LANGFUSE_IN_APP_AGENT_SANDBOX_PROVIDER;
- process.env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION ??= "DEV";
- process.env.NEXTAUTH_URL ??= "http://localhost:3000";
- process.env.LANGFUSE_AI_PROVIDER ??= "bedrock";
- process.env.LANGFUSE_AI_AWS_BEDROCK_REGION ??= "eu-central-1";
- process.env.LANGFUSE_AI_MODEL ??= "test-bedrock-model";
+ if (process.env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION === undefined) {
+ process.env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION = "DEV";
+ }
+ if (process.env.NEXTAUTH_URL === undefined) {
+ process.env.NEXTAUTH_URL = "http://localhost:3000";
+ }
+ if (process.env.LANGFUSE_AI_PROVIDER === undefined) {
+ process.env.LANGFUSE_AI_PROVIDER = "bedrock";
+ }
+ if (process.env.LANGFUSE_AI_AWS_BEDROCK_REGION === undefined) {
+ process.env.LANGFUSE_AI_AWS_BEDROCK_REGION = "eu-central-1";
+ }
+ if (process.env.LANGFUSE_AI_MODEL === undefined) {
+ process.env.LANGFUSE_AI_MODEL = "test-bedrock-model";
+ }
});
/**
diff --git a/worker/src/features/in-app-agent/executeInAppAgentRun.ts b/worker/src/features/in-app-agent/executeInAppAgentRun.ts
index 102299ba68..41c9e2c484 100644
--- a/worker/src/features/in-app-agent/executeInAppAgentRun.ts
+++ b/worker/src/features/in-app-agent/executeInAppAgentRun.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { Role } from "@langfuse/shared";
import { prisma } from "@langfuse/shared/src/db";
import {
@@ -176,14 +175,16 @@ export async function executeInAppAgentRun(params: {
const cleanupMcpApiKey = (): Promise<void> => {
if (!mcpApiKey) return Promise.resolve();
const keyId = mcpApiKey.id;
- mcpApiKeyCleanup ??= (async () => {
- await deleteInAppAgentMcpApiKey({ projectId, apiKeyId: keyId });
- // Pointer is nulled after delete succeeds or the key is already gone.
- await clearRunMcpApiKeyPointer({ prisma, projectId, runId });
- })().catch((error: unknown) => {
- mcpApiKeyCleanup = undefined;
- throw error;
- });
+ if (mcpApiKeyCleanup === undefined) {
+ mcpApiKeyCleanup = (async () => {
+ await deleteInAppAgentMcpApiKey({ projectId, apiKeyId: keyId });
+ // Pointer is nulled after delete succeeds or the key is already gone.
+ await clearRunMcpApiKeyPointer({ prisma, projectId, runId });
+ })().catch((error: unknown) => {
+ mcpApiKeyCleanup = undefined;
+ throw error;
+ });
+ }
return mcpApiKeyCleanup;
};
diff --git a/worker/src/features/in-app-agent/runtime/agent.ts b/worker/src/features/in-app-agent/runtime/agent.ts
index c02dc1a238..15aa9bd153 100644
--- a/worker/src/features/in-app-agent/runtime/agent.ts
+++ b/worker/src/features/in-app-agent/runtime/agent.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { EventType } from "@ag-ui/core";
import { MastraAgent } from "@ag-ui/mastra";
import { IN_APP_AGENT_SYSTEM_PROMPT_TEMPLATE } from "@langfuse/shared/in-app-agent/server/systemPrompt";
@@ -464,7 +463,9 @@ export async function createAgUiStream(params: {
};
const runOnFinish = () => {
- onFinishPromise ??= Promise.resolve(params.options.onFinish?.());
+ if (onFinishPromise === undefined) {
+ onFinishPromise = Promise.resolve(params.options.onFinish?.());
+ }
return onFinishPromise;
};
diff --git a/worker/src/features/in-app-agent/runtime/instrumentation.ts b/worker/src/features/in-app-agent/runtime/instrumentation.ts
index 144ae55f5a..28e2ab126b 100644
--- a/worker/src/features/in-app-agent/runtime/instrumentation.ts
+++ b/worker/src/features/in-app-agent/runtime/instrumentation.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { EventType } from "@ag-ui/core";
import { Buffer } from "node:buffer";
import { getInternalTracingHandler, logger } from "@langfuse/shared/src/server";
@@ -347,7 +346,9 @@ export class InAppAgentInstrumentation {
}
const times = this.toolExecutionTimes.get(toolCallId) ?? {};
- times.startTime ??= new Date();
+ if (times.startTime === undefined) {
+ times.startTime = new Date();
+ }
this.toolExecutionTimes.set(toolCallId, times);
}
@@ -357,7 +358,9 @@ export class InAppAgentInstrumentation {
}
const times = this.toolExecutionTimes.get(toolCallId) ?? {};
- times.endTime ??= new Date();
+ if (times.endTime === undefined) {
+ times.endTime = new Date();
+ }
this.toolExecutionTimes.set(toolCallId, times);
}
@@ -395,7 +398,9 @@ export class InAppAgentInstrumentation {
const now = new Date();
if (type === "text-delta" || type === "reasoning-delta") {
- this.openModelCall.completionStartTime ??= now;
+ if (this.openModelCall.completionStartTime === undefined) {
+ this.openModelCall.completionStartTime = now;
+ }
if (type === "text-delta" && typeof part.delta === "string") {
this.openModelCall.textDeltas.push(part.delta);
}
@@ -505,9 +510,11 @@ export class InAppAgentInstrumentation {
}
flush(): Promise<void> {
- this.flushPromise ??= this.processTracedEvents().catch((error) => {
- logger.warn("Failed to flush in-app agent Langfuse tracing", error);
- });
+ if (this.flushPromise === undefined) {
+ this.flushPromise = this.processTracedEvents().catch((error) => {
+ logger.warn("Failed to flush in-app agent Langfuse tracing", error);
+ });
+ }
return this.flushPromise;
}
diff --git a/worker/src/queues/otelIngestionQueue.ts b/worker/src/queues/otelIngestionQueue.ts
index d6661abba4..fd9c287beb 100644
--- a/worker/src/queues/otelIngestionQueue.ts
+++ b/worker/src/queues/otelIngestionQueue.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @repo/no-exotic-operators */
import { Job, Processor } from "bullmq";
import { z } from "zod";
import {
@@ -561,7 +560,9 @@ export const otelIngestionQueueProcessorBuilder = (
.map((o) => ingestionSchema.safeParse(o))
.flatMap((o) => {
if (!o.success) {
- firstParseError ??= o.error;
+ if (firstParseError === undefined) {
+ firstParseError = o.error;
+ }
return [];
}
return [o.data];