Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError Function.assign(<anonymous>): RunTree is not defined #7546

Open
5 tasks done
FaresKi opened this issue Jan 18, 2025 · 7 comments
Open
5 tasks done

ReferenceError Function.assign(<anonymous>): RunTree is not defined #7546

FaresKi opened this issue Jan 18, 2025 · 7 comments
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@FaresKi
Copy link
Contributor

FaresKi commented Jan 18, 2025

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

The code isn't the issue, I believe there's an underlying issue in the dependencies or an incompatibility with the node version.

Error Message and Stack Trace (if applicable)

2025-01-18T00:36:33.251431725Z ReferenceError: RunTree is not defined
2025-01-18T00:36:33.251510436Z     at Function.assign (<anonymous>)
2025-01-18T00:36:33.251521661Z     at file:///app/node_modules/.pnpm/[email protected][email protected][email protected][email protected]_/node_modules/langsmith/dist/index.js?iitm=true:6:18
2025-01-18T00:36:33.251530248Z     at ModuleJob.run (node:internal/modules/esm/module_job:271:25)
2025-01-18T00:36:33.251538199Z     at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26)
2025-01-18T00:36:33.251546401Z     at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)
2025-01-18T00:36:37.401177518Z (node:1) ExperimentalWarning: Use `importAttributes` instead of `importAssertions`
2025-01-18T00:36:37.401257271Z     at emitImportAssertionWarning (node:internal/modules/esm/hooks:74:13)
2025-01-18T00:36:37.401292368Z     at Object.get (node:internal/modules/esm/hooks:83:7)
2025-01-18T00:36:37.401307087Z     at resolve (/app/node_modules/.pnpm/[email protected]/node_modules/import-in-the-middle/hook.js:366:16)
2025-01-18T00:36:37.401319100Z     at async nextResolve (node:internal/modules/esm/hooks:748:22)
2025-01-18T00:36:37.401329891Z     at async Hooks.resolve (node:internal/modules/esm/hooks:240:24)
2025-01-18T00:36:37.401358276Z     at async handleMessage (node:internal/modules/esm/worker:199:18)

Description

  • Trying to start my app
  • Run into this bug

System Info

➜ pnpm info langchain

[email protected] | MIT | deps: 12 | versions: 306
Typescript bindings for langchain
https://github.com/langchain-ai/langchainjs/tree/main/langchain/

keywords: llm, ai, gpt3, chain, prompt, prompt engineering, chatgpt, machine learning, ml, openai, embeddings, vectorstores

dist
.tarball: https://registry.npmjs.org/langchain/-/langchain-0.3.11.tgz
.shasum: dbfadf47aaffc23fc0ac80c953c41fe8176614c9
.integrity: sha512-PgAG4ZLeuSRkKsyf98cmWGdwKv3I1hOFC8a4fr7e+bm7E+F6Fx6xUkgbuC78ff0N/Cjs5BBryZIFMrqoKPqsvg==
.unpackedSize: 2.9 MB

dependencies:
@langchain/openai: >=0.1.0 <0.4.0 jsonpointer: ^5.0.1 uuid: ^10.0.0
@langchain/textsplitters: >=0.0.0 <0.2.0 langsmith: ^0.2.8 yaml: ^2.2.1
js-tiktoken: ^1.0.12 openapi-types: ^12.1.3 zod-to-json-schema: ^3.22.3
js-yaml: ^4.1.0 p-retry: 4 zod: ^3.22.4

maintainers:

dist-tags:
latest: 0.3.11 tag-for-publishing-older-releases: 0.2.20
next: 0.3.2-rc.0

published a week ago by jacoblee93 [email protected]

node version: 22
platform: linux

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Jan 18, 2025
Copy link

dosubot bot commented Jan 18, 2025

The error "ReferenceError: RunTree is not defined" suggests that there might be an issue with the RunTree implementation or its integration in your setup. The RunTree is defined in the LangChain.js codebase in the file langchain/src/smith/runner_utils.ts and is used for managing execution flow and callbacks [1].

Given that you're using Node.js version 22, which is not officially supported by LangChain.js (as it supports Node.js versions 18.x to 20.x), this could be a compatibility issue. You might want to try using a supported Node.js version to see if that resolves the issue.

Additionally, ensure that all dependencies are correctly installed and compatible with LangChain.js version 0.3.11. You can verify the dependencies listed in the package.json file to ensure they match the required versions [2].

If the issue persists after these checks, it might be worth investigating if there are any specific changes in the langsmith package version 0.2.15 that could affect its integration with LangChain.js, as this package is mentioned in the stack trace.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@jacoblee93
Copy link
Collaborator

Strange - any other context/sample code you can give?

@FaresKi
Copy link
Contributor Author

FaresKi commented Jan 18, 2025

This seems to be a package ecosystem version issue.
It was working good for the following versions:

  • @langchain/anthropic 0.3.11
  • @langchain/community 0.3.20
  • @langchain/core 0.3.26
  • @langchain/langgraph 0.2.36
  • @langchain/openai 0.3.16
  • @langchain/qdrant 0.1.1
  • langchain 0.3.8
  • langfuse-langchain 3.32.0

However when upgrading to the latest versions, this issue appeared. Pretty strange, it stopped the app from starting. Interesting to note that the building wasn't the issue.
Here's my tsconfig:

{
	"extends": "fastify-tsconfig",
	"compilerOptions": {
		"outDir": "dist",
		"sourceMap": true,
		"baseUrl": ".",
		"paths": {
			"@/*": ["./src/*"]
		},
		"module": "ESNext",
		"moduleResolution": "Bundler",
		"target": "ESNext",
		"esModuleInterop": true,
		"allowSyntheticDefaultImports": true,
		"skipLibCheck": true,
		"isolatedModules": true,
		"resolveJsonModule": true,
		"strict": true,
		"inlineSources": true,
		// Set `sourceRoot` to  "/" to strip the build path prefix
		// from generated source code references.
		// This improves issue grouping in Sentry.
		"sourceRoot": "/"
	},
	"include": ["src/**/*", "test/**/*"],
	"exclude": ["node_modules"]
}

Maybe @dosu could be of help?

Copy link

dosubot bot commented Jan 18, 2025

The "ReferenceError: RunTree is not defined" issue you're encountering might be due to changes in the import path for the RunTree class in the latest versions of the LangChain packages. In the latest version of the langsmith package, the correct import path for RunTree is:

import { RunTree } from "langsmith";

Ensure that your code is using this import path. If your code was previously using a different path, such as "langsmith/run_trees", updating it to the new path should resolve the issue [1][2].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@jacoblee93
Copy link
Collaborator

Maybe try removing langfuse and seeing what happens?

They might be using RunTree or patching it somehow

@guidev
Copy link
Contributor

guidev commented Jan 31, 2025

same here

@jeloi
Copy link

jeloi commented Feb 3, 2025

Also getting this issue, very specifically when adding this opentelemetry instrumentation hook line (the last line in this command):

NODE_CMD="NODE_ENV=development node \
  --loader ts-node/esm \
  --conditions=development \
  --experimental-specifier-resolution=node \
  --experimental-loader=@opentelemetry/instrumentation/hook.mjs"

Relevant documentation here: https://github.com/open-telemetry/opentelemetry-js/blob/main/doc/esm-support.md#instrumentation-hook-required-for-esm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

4 participants