langchain-ai / langchainjs

🦜🔗 Build context-aware reasoning applications 🦜🔗
https://js.langchain.com/docs/
MIT License
12.29k stars 2.08k forks source link

vscode debugger doesn't break on breakpoints #1978

Closed tonisives closed 9 months ago

tonisives commented 1 year ago

Here is my launch configuration. (

    {
      "type": "node",
      "request": "launch",
      "name": "test",
      "outputCapture": "std",
      "runtimeExecutable": "yarn",
      "args": [
        "test:single",
        "src/tests/text_splitter.test.ts"
      ]
    }

Usually, when running with similar configurations, the debugger breaks just fine. But not in langchain repo.

The code runs fine and logs the output. It just doesn't break.

dosubot[bot] commented 1 year ago

Answer generated by a 🤖

Answer

I'm sorry to hear that you're experiencing issues with the VSCode debugger not breaking on breakpoints. Based on the information you provided, it seems like you have a valid launch configuration.

Here are a few suggestions to help troubleshoot the issue:

  1. Verify that breakpoints are set correctly: Double-check that you have set breakpoints in the code where you expect the debugger to break. Make sure the breakpoints are not disabled or conditional.

  2. Check the file path: Ensure that the file path specified in the launch configuration (src/tests/text_splitter.test.ts) matches the actual location of the file in your project.

  3. Try a different debugging mode: Instead of using the "node" debugging mode, you can try using the "auto" mode. This mode automatically detects the runtime and may help resolve any compatibility issues.

  4. Update VSCode and extensions: Make sure you are using the latest version of VSCode and any relevant extensions, such as the Node.js extension. Outdated versions can sometimes cause compatibility issues.

  5. Check for conflicting extensions: Disable any other extensions that might interfere with the debugger, especially those related to testing or code coverage.

If none of these suggestions resolve the issue, please provide more details about your environment, such as the version of VSCode, the version of the Node.js runtime, and any relevant extensions you have installed. Additionally, any error messages or warnings displayed in the VSCode debug console would be helpful in diagnosing the problem.

Let me know if you have any further questions or if there's anything else I can assist you with.


This response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

tonisives commented 1 year ago

The AI response is not helpful. I am attaching the problem as a gif. For my other TS projects, the vscode breaks normally

out

dosubot[bot] commented 1 year ago

Answer generated by a 🤖

Answer

Hello,

Based on the information you've provided, there are a few things that could be causing the issue with the VSCode debugger not breaking on breakpoints in your LangChain project.

Firstly, it's important to note that the sourceMap option is not present in your tsconfig.json. This option is often used to enable source map support for debugging TypeScript code in VSCode. If you're having issues with debugging, you might want to add "sourceMap": true to your tsconfig.json.

Secondly, the test:single script is not present in the package.json file of the LangChain project. The available scripts are build, test, test:esm, test:cjs, format, and format:check. If you've added the test:single script yourself, please ensure that it's correctly configured to run the test file you're trying to debug.

Lastly, I'm unable to view the gif you've attached as I can't process images. However, if the issue is specific to the LangChain project, it might be related to the project's specific configuration or structure.

Please try the suggestions above and let me know if the issue persists. If it does, could you please provide more information about your project's structure and configuration, especially any changes you've made to the default LangChain setup? This will help me better understand the issue and provide a more accurate solution.

Best regards.

Sources


This response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

tonisives commented 1 year ago

I got debugging working by attaching to a console process

node --inspect-brk node_modules/.bin/jest --runInBand --config langchain/jest.config.cjs langchain/src/tests/text_splitter.test.ts

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "attach",
      "name": "Attach",
      "port": 9229
    }
  ]
}

What launch configuration do you use to make the debugger work straight in vscode(without the command line step)?

PS: the AI bot is not helpful and I think just spamming the conversation.

dosubot[bot] commented 9 months ago

Hi, @tonisives,

I'm helping the langchainjs team manage their backlog and am marking this issue as stale. From what I understand, you were experiencing issues with the VSCode debugger not breaking on breakpoints in a specific repository. After trying various troubleshooting steps, you were able to get debugging working by attaching to a console process, but still sought advice on the appropriate launch configuration to make the debugger work directly in VSCode.

Could you please confirm if this issue is still relevant to the latest version of the langchainjs repository? If it is, please let the langchainjs team know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days. Thank you!