Skip to content

CppTools extension should handle expected timeouts without throwing uncaught exceptions. #10634

Description

Environment

  • OS and Version: Windows 11 Selfhost (latest version)
  • VS Code Version: 1.76.0
  • C/C++ Extension Version: 1.14.4
  • If using SSH remote, specify OS of remote machine:

Bug Summary and Steps to Reproduce

Bug Summary:
When executing our extension tests under VSCode's debugger, it constantly hits an uncaught exception due to timeouts (which are actually expected when CppTools calls into our extension)

The implementation of "callTaskWithTimeout" should be authored in a way that doesn't throw uncaught exceptions if the timeout occurs.

                });
                const configs = yield this.callTaskWithTimeout(provideConfigurationAsync, configProviderTimeout, tokenSource);
                try {

    callTaskWithTimeout(task, ms, cancelToken) {
        let timer;
        const timeout = () => new Promise((resolve, reject) => {
            timer = global.setTimeout(() => {
                clearTimeout(timer);
                if (cancelToken) {
                    cancelToken.cancel();
                }
                reject(localize(27, null, ms));
            }, ms);
        });
        return Promise.race([task(), timeout()]).then((result) => {
            clearTimeout(timer);
            return result;
        }, (error) => {
            clearTimeout(timer);
            throw error;
        });
    }

Steps to reproduce:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior:

Configuration and Logs

N/A

Other Extensions

All extensions disabled except for WAVE for VSCode (Windows IntelliSense Information Provider)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions