Skip to content

Optimize closeActiveWindows to reduce likelihood of test timeouts resulting in CI failures #4247

@DonJayamanne

Description

@DonJayamanne

Currently we have a few timeouts when invoking VSC API to close documents.
Possible improvements:

  • Invoke workbench.action.closeAllEditors with a very short timeout (1s)
  • Check if any documents are opened before invoking this
  • Attempt to close the active editor before invoking this
  • Iterate through editors, show the document one by one and close the docs
  • Finally attempt workbench.action.closeAllEditors with the 15s timeout.

The code is as follows:

export async function closeActiveWindows(): Promise<void> {
    return new Promise<void>((resolve, reject) => {
        vscode.commands.executeCommand('workbench.action.closeAllEditors')
            // tslint:disable-next-line:no-unnecessary-callback-wrapper
            .then(() => resolve(), reject);
        // Attempt to fix #1301.
        // Lets not waste too much time.
        setTimeout(() => {
            reject(new Error('Command \'workbench.action.closeAllEditors\' timed out'));
        }, 15000);
    });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-internalLabel for non-user facing issuesdebtCovers everything internal: CI, testing, refactoring of the codebase, etc.needs PRReady to be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions