Skip to content

[Feature] LogCat array arguments are merged, causing command-line options to fail #3076

Open

Description

@ZhiyanJia

Description

When debugging an Android app, I want to view only that app's logs instead of logs from all processes on the device. LogCat supports --pid <pid> for this purpose.

However, setting react-native.android.logCatArguments to ["--pid", "<pid>"] causes the extension to merge the two arguments into --pid,<pid>. LogCat rejects this as an unknown option, preventing the monitor from starting correctly.

Steps to reproduce

  1. Open a React Native project in an Extension Development Host window.

  2. Start an Android emulator and run the app.

  3. Query the running app's PID:

    adb -s emulator-5554 shell pidof com.rn_0_87_1

    In my case, the PID was 16658.

  4. To show only this app's logs, open Preferences: Open Workspace Settings (JSON) from the Command Palette and add:

    {
      "react-native.android.logCatArguments": [
        "--pid",
        "16658"
      ]
    }

    Replace 16658 with the current app PID.

  5. Save the settings and run React Native: Run React Native LogCat Monitor from the Command Palette.

Expected behavior

The extension passes --pid and 16658 as separate arguments:

["-s", "emulator-5554", "logcat", "--pid", "16658"]

LogCat starts and displays only logs from the specified app process.

Actual behavior

The Output panel shows:

[Debug] Monitoring LogCat for device emulator-5554 with arguments: --pid,16658

Since this log message alone does not distinguish separate array elements, I also inspected the arguments at a breakpoint in AdbHelper.startLogCat():

this.adbExecutable.replace(/"/g, "")
'adb'

JSON.stringify(adbParameters)
'["-s","emulator-5554","logcat","--pid,16658"]'

The extension therefore launches the equivalent of:

adb -s emulator-5554 logcat "--pid,16658"

Verified impact

Running the correct arguments directly in a terminal returns the app's logs:

adb -s emulator-5554 logcat -d --pid 16658

Running the merged argument produces an error:

adb -s emulator-5554 logcat -d "--pid,16658"
logcat: Unknown option '(null)'.

The -d flag is used only for the terminal comparison so the command exits after dumping existing logs.

Cause

In src/extension/android/logCatMonitor.ts, getLogCatArguments() converts the array to a string and then splits it on spaces:

String(this._userProvidedLogCatArguments).split(" ")

JavaScript joins array elements with commas:

["--pid", "16658"] → "--pid,16658" → ["--pid,16658"]

Array inputs should preserve their argument boundaries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions