Skip to content

Handle command too long failure in typings installer #23374

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

Merged
merged 1 commit into from
Apr 12, 2018

Conversation

sheetalkamat
Copy link
Member

In the logs provided in microsoft/vscode#46025 , typing installer failed to install type packages because the command was too long. When TI installer fails, there is no attempt to reinstall which means user doesnt get intellisense from these typings hence we should avoid TI installation failures whenever possible.

@sheetalkamat sheetalkamat merged commit a9ffabb into master Apr 12, 2018
@sheetalkamat sheetalkamat deleted the npmInstallCommandTooLong branch April 12, 2018 21:17
@@ -30,6 +30,31 @@ namespace ts.server.typingsInstaller {
}
}

/*@internal*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems needlessly confusing. How about something like this?

    /*@internal*/
    export function installNpmPackages(npmPath: string, tsVersion: string, packageNames: string[], install: (command: string) => boolean) {
        let hasError = false;
        const remaining = packageNames.slice();
        while (!hasError && remaining.length > 0) {
            const batch = takePackages(remaining);
            const command = `${npmPath} install --ignore-scripts ${batch.join(" ")} --save-dev --user-agent="typesInstaller/${tsVersion}"`;
            hasError = install(command) || hasError;
        }
        return hasError;
}

    function takePackages(packages: string[]): string[] {
        let remainder = 7500;
        const result: string[] = [];
        while (packages.length > 0 && remainder > 0) {
            const p = packages.pop();
            remainder -= (p.length + 1); // +1 for space
            result.push(p);
        }        
        return result;
    }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont want to create duplicate array if cmd is going to succeed. But let me see if i can infuse this with my approach and comeup with something better.

@sheetalkamat
Copy link
Member Author

@mhegazy do we want this for 2.8.3 ?

@mhegazy
Copy link
Contributor

mhegazy commented Apr 12, 2018

I think we are done for 2.8.3 for now. we already snapped the VS release.

@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants