Skip to content

Duplicated launch configs #12153

@marcdumais-work

Description

@marcdumais-work

Bug Description:

I've been working to improve the browser test suite and when I updated my baseline to include the content of the most recent master branch, over 100 tests from launch-preferences.spec.js suddenly started consistently failing.

This test file is a bit obscure, but I think the fundamental reason for the failures is that we end-up with duplicated launch configurations, whenever the preferences machinery evaluates them. I have traced the issue to PR #12126, which makes a change in PreferenceProvider.

Note: the browser test suite has been very flaky lately, so it's no surprise its failures ends-up being not noticed during PR reviews. Additionally, the new failures related to the launch preferences generate so many error traces that I think the GitHub runner gets overwhelmed and ends-up not showing the detailed errors at the end of execution, which makes it very hard to notice that there are additional new failures (vs the usual ones).

To run the failing test file locally and get access to the full output log:

  1. build the Theia repo from sources: yarn && yarn browser build && yarn download:plugins
  2. cd examples/browser
  3. yarn -s rebuild && npx theia test . --plugins=local-dir:../../plugins --test-spec=../api-tests/src/launch-preferences.spec.js

update: If the test failure traces are still not present in the output, try running in non-headless mode:
yarn -s rebuild && npx theia test . --plugins=local-dir:../../plugins --test-inspect --test-spec=../api-tests/src/launch-preferences.spec.js

Steps to Reproduce:

  1. Build the Theia repo from sources
  2. Use the example Theia application to open folder examples/browser as your workspace
  3. Switch to the debug view.
  4. Trigger the launch drop-down and select Add Configuration and select a type of launch (e.g.: "Node.js: Launch Program")
  5. Trigger the launch drop-down again and confirm that two launches are listed, under the name of the new added launch (e.g. "Launch Program"

Alternatively, open the Theia repo root folder as a workspace and confirm that all launch are duplicated (some maybe more than one time).

The same duplication happens if one adds a launch to the settings.json file.

See this video capture:
duplicated launches

Additional Information

Not sure if it might help, but while debugging I have added some printouts to preferences-provider.ts and captured the following traces, when adding a launch configuration, using the reproduce steps above:

static merge(source: JSONValue | undefined, target: JSONValue): JSONValue {
        const origSource = source;
        if (source === undefined || !JSONExt.isObject(source)) {
            return JSONExt.deepCopy(target);
        }
        if (JSONExt.isPrimitive(target)) {
            return {};
        }
        for (const key of Object.keys(target)) {
            const value = (target as any)[key];
            if (key in source) {
                if (JSONExt.isObject(source[key]) && JSONExt.isObject(value)) {
                    this.merge(source[key], value);
                    continue;
                } else if (JSONExt.isArray(source[key]) && JSONExt.isArray(value)) {
                    console.log('\n\n');
                    console.log('%%%% merge: source: ' + JSON.stringify(origSource));
                    console.log('%%%% merge: target: ' + JSON.stringify(target));
                    console.log('********************** source[key] and value are both arrays');
                    console.log('********************** key          :       ' + key);
                    console.log('********************** value target[key]    ' + JSON.stringify(value));
                    console.log('********************** source b4 update:    ' + JSON.stringify(source));
                    source[key] = [...JSONExt.deepCopy(source[key] as any), ...JSONExt.deepCopy(value)];
                    console.log('********************** updated source:      ' + JSON.stringify(source) + '\n\n)');
                    continue;
                }
            }
            source[key] = JSONExt.deepCopy(value);
        }
        return source;
    }
2023-02-06T17:43:59.168Z root INFO %%%% merge: source: {"configurations":[],"compounds":[],"version":"0.2.0"}
2023-02-06T17:43:59.168Z root INFO %%%% merge: target: {"version":"0.2.0","configurations":[{"name":"Launch Program","program":"${workspaceFolder}/app.js","request":"launch","skipFiles":["<node_internals>/**"],"type":"node"}]}
2023-02-06T17:43:59.168Z root INFO ********************** source[key] and value are both arrays
2023-02-06T17:43:59.168Z root INFO ********************** key          :       configurations
2023-02-06T17:43:59.168Z root INFO ********************** value target[key]    [{"name":"Launch Program","program":"${workspaceFolder}/app.js","request":"launch","skipFiles":["<node_internals>/**"],"type":"node"}]
2023-02-06T17:43:59.168Z root INFO ********************** source b4 update:    {"configurations":[],"compounds":[],"version":"0.2.0"}
2023-02-06T17:43:59.168Z root INFO ********************** updated source:      {"configurations":[{"name":"Launch Program","program":"${workspaceFolder}/app.js","request":"launch","skipFiles":["<node_internals>/**"],"type":"node"}],"compounds":[],"version":"0.2.0"}

)
2023-02-06T17:43:59.168Z root INFO 


2023-02-06T17:43:59.168Z root INFO %%%% merge: source: {"configurations":[{"name":"Launch Program","program":"${workspaceFolder}/app.js","request":"launch","skipFiles":["<node_internals>/**"],"type":"node"}],"compounds":[],"version":"0.2.0"}
2023-02-06T17:43:59.168Z root INFO %%%% merge: target: {"version":"0.2.0","configurations":[{"name":"Launch Program","program":"${workspaceFolder}/app.js","request":"launch","skipFiles":["<node_internals>/**"],"type":"node"}]}
2023-02-06T17:43:59.168Z root INFO ********************** source[key] and value are both arrays
2023-02-06T17:43:59.168Z root INFO ********************** key          :       configurations
2023-02-06T17:43:59.168Z root INFO ********************** value target[key]    [{"name":"Launch Program","program":"${workspaceFolder}/app.js","request":"launch","skipFiles":["<node_internals>/**"],"type":"node"}]
2023-02-06T17:43:59.168Z root INFO ********************** source b4 update:    {"configurations":[{"name":"Launch Program","program":"${workspaceFolder}/app.js","request":"launch","skipFiles":["<node_internals>/**"],"type":"node"}],"compounds":[],"version":"0.2.0"}
2023-02-06T17:43:59.168Z root INFO ********************** updated source:      {"configurations":[{"name":"Launch Program","program":"${workspaceFolder}/app.js","request":"launch","skipFiles":["<node_internals>/**"],"type":"node"},{"name":"Launch Program","program":"${workspaceFolder}/app.js","request":"launch","skipFiles":["<node_internals>/**"],"type":"node"}],"compounds":[],"version":"0.2.0"}

)
  • Operating System:
  • Theia Version:

Metadata

Metadata

Labels

debugissues that related to debug functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions