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

Debugger keeps sending telemetry CDP requests to a debuggee in an infinite loop #981

Closed
RedMickey opened this issue Apr 29, 2021 · 1 comment
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@RedMickey
Copy link

Hello,
I'm a maintainer of React Native Tools VS Code extension. The extension is used for debugging React Native applications. Under the hood the extension uses vscode-js-debug debugger to debug javascript apps.

Describe the bug
While debugging React Native applications, we found out that js-debug sends the CDP request to a debuggee to get some data for telemetry. js-debug keeps sending that request, in case the debuggee returns process not defined string. Due to the peculiarities of debugging React Native Hermes applications the debuggee always returns process not defined string as a result.

[Reply From Debugger To Target] {
  "id": 1043,
  "method": "Runtime.evaluate",
  "params": {
    "contextId": 1,
    "returnByValue": true,
    "expression": "typeof process === 'undefined' || process.pid === undefined ? 'process not defined' : ({ processId: process.pid, nodeVersion: process.version, architecture: process.arch })\n//# sourceURL=eval-8907f309.cdp\n"
  }
}

[Reply From Target To Debugger] {
  "result": {
    "result": {
      "type": "string",
      "value": "process not defined"
    }
  },
  "id": 1043
}

Therefore, js-debug sends the Runtime.evaluate request in an infinite loop here.
This behavior doesn't break debugging, but it could reduce performance.

It might make sense to add several retries to get process data in gatherTelemetryFromCdp function (e.g. like here) to prevent infinite sending of the CDP request.

To Reproduce
Steps to reproduce the behavior:

  1. Prepare the development environment for React Native Android apps using this guide
  2. Create a plain RN app using the command npx react-native init AwesomeProject
  3. Enable Hermes engine for Android following the guide
  4. Launch the RN app using the command npx react-native run-android
  5. Open the project in VS Code and create the debugging configuration:
  {
    "type": "pwa-node",
    "request": "attach",
    "name": "Attach pwa-node",
    "port": 8081,
    "resolveSourceMapLocations": ["**", "!**/node_modules/**"],
    "continueOnAttach": true
  }
  1. Attach to the application using the created debugging configuration
  2. After that js-debug should attach to the app. Breakpoint won't work since some additional processing is need (this is implemented in React Native Tools extension), but debugging console should work correctly
  3. Then you can set a breakpoint in gatherTelemetryFromCdp function here, and it will be reached over and over again after the successful attachment

Log Files: vscode-debugadapter-c33e8880.json.gz, CDPlogs.txt

VS Code Version: 1.55.2

@RedMickey RedMickey added the bug Issue identified by VS Code Team member as probable bug label Apr 29, 2021
@connor4312
Copy link
Member

sure, I think giving up after half a second or so is fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

2 participants