Skip to content

Error message when using Bun as the engine #5260

@lostbean

Description

@lostbean

What happened?

Steps to Reproduce

Follow the any basic example of using Phoenix but Bun as the engine.

Actual Result

The logs are send and received by the Phoenix service but an error message is logged in the client for every request.

Expected Result

Keep sending the logs but no error messages in the client side.

Additional Details

Switch the JS engine to Node.js makes the system work normally with any error message.

OpenTelemetry Setup Code

import { LangChainInstrumentation } from "@arizeai/openinference-instrumentation-langchain";
import { SEMRESATTRS_PROJECT_NAME } from "@arizeai/openinference-semantic-conventions";
import * as CallbackManagerModule from "@langchain/core/callbacks/manager";
import { diag, DiagConsoleLogger, DiagLogLevel } from "@opentelemetry/api";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
import { Resource } from "@opentelemetry/resources";
// import { ConsoleSpanExporter } from "@opentelemetry/sdk-trace-base";
import {
  NodeTracerProvider,
  SimpleSpanProcessor,
} from "@opentelemetry/sdk-trace-node";
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";

export function setupTracing() {
  // For troubleshooting, set the log level to DiagLogLevel.DEBUG
  diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);

  const provider = new NodeTracerProvider({
    resource: new Resource({
      [ATTR_SERVICE_NAME]: "user-load-agent",
      [SEMRESATTRS_PROJECT_NAME]: "user-load-agent",
    }),
  });

  const otlpExporter = new OTLPTraceExporter({
    timeoutMillis: 50000,
  });

  // provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
  provider.addSpanProcessor(new SimpleSpanProcessor(otlpExporter));

  const lcInstrumentation = new LangChainInstrumentation();
  // LangChain must be manually instrumented as it doesn't have a traditional module structure
  lcInstrumentation.manuallyInstrument(CallbackManagerModule);

  provider.register();

  // eslint-disable-next-line no-console
  console.log("👀 OpenInference initialized");

  return {
    forceFlush: async () => {
      otlpExporter.forceFlush();
      provider.forceFlush();
    },
  };
}

package.json

{
  "name": "myapp",
  "private": true,
  "version": "1.0.0",
  "type": "module",
  "module": "src/client.ts",
  "scripts": {
    "build": "tsc",
    "start": "bun run dist/client.js",
    "dev": "bun run --watch src/client.ts"
  },
  "engines": {
    "bun": "1.1.37"
  },
  "dependencies": {
    "@anthropic-ai/sdk": "^0.32.1",
    "@arizeai/openinference-instrumentation-langchain": "^0.2.0",
    "@opentelemetry/exporter-trace-otlp-http": "^0.49.1",
    "@opentelemetry/exporter-trace-otlp-proto": "^0.56.0",
    "@opentelemetry/sdk-trace-base": "^1.22.0",
    "@opentelemetry/sdk-trace-node": "^1.22.0",
    "dotenv": "^16.4.5",
    "express": "^4.21.1",
    "langchain": "^0.3.5",
    "typescript": "^5.6.3",
    "uuid": "^11.0.3",
    "ws": "^8.18.0"
  },
  "devDependencies": {
    "@types/bun": "latest",
    "@types/express": "^5.0.0",
    "@types/ws": "^8.5.13",
    "typescript": "^5.6.3"
  },
  "peerDependencies": {
    "prettier": "^3.3.3",
    "eslint": "^8"
  },
  "prettier": {}
}

Relevant log output

{"message":"Request timed out","originalLine":"59","originalColumn":"25","line":"87","column":"24","sourceURL":"/code/node_modules/@opentelemetry/exporter-trace-otlp-proto/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/http-transport-utils.js","stack":"Error: Request timed out\n    at <anonymous> (/code/node_modules/@opentelemetry/exporter-trace-otlp-proto/node_modules/@opentelemetry/otlp-exporter-base/build/src/transport/http-transport-utils.js:87:24)\n    at emit (node:events:183:48)\n    at emitCloseNT (node:http:191:21)\n    at <anonymous> (node:http:1074:18)\n    at <anonymous> (native:19:28)\n    at processTicksAndRejections (native:7:39)","name":"Error"}

Operating System and Version

macOS 15.1

Runtime and Version

bun 1.1.31, Node.js v20.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghas:reproducerThis bug/feature has a minimal reproducer providedruntime:bunUnsupported Runtime Bun

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions