powerplatform-vscode icon indicating copy to clipboard operation
powerplatform-vscode copied to clipboard

Fix Power Pages generator installation error detection on restricted networks (UsGov systems)

Open Copilot opened this issue 4 months ago • 2 comments

Problem

On restricted network environments such as UsGov systems, Power Pages generator installation was failing silently. Users would see "Installing Power Pages generator..." message but npm would fail without proper error detection or user feedback, leaving the generator uninstalled and commands unavailable.

Root Cause

The GeneratorAcquisition.ensureInstalled() method only checked child.error from spawnSync, but on restricted networks npm could fail with a non-zero exit code without setting the error object. This caused:

  1. npm install failures going undetected
  2. No error messages shown to users
  3. Generator remaining uninstalled (yoCommandPath null)
  4. Commands not being registered (as designed - generator is required)
  5. Users having no feedback about what went wrong

Solution

Enhanced Error Detection (GeneratorAcquisition.ts)

Now checks both child.error AND child.status for npm install failures:

// Before: Only checked child.error
if (child.error) { ... }

// After: Checks both error object and exit code
if (child.error || child.status !== 0) {
    const errorMessage = child.error 
        ? String(child.error) 
        : `npm install exited with code ${child.status}`;
    // ... improved error handling with exit code in telemetry
}

This ensures:

  • npm failures are properly detected even when error object is not set
  • Users see clear error messages about installation failures
  • Exit codes are logged in telemetry for diagnostics
  • Commands remain unregistered when installation fails (generator is required for commands to work)

Impact

Better error detection: Properly detects npm failures on restricted networks
Better diagnostics: Exit codes logged in telemetry for troubleshooting
Clear user feedback: Users see error messages when installation fails
Backwards compatible: No changes to command registration logic
Works on restricted networks: Properly handles npm failures on UsGov systems

Behavior

  1. On successful installation: Commands register and work as before
  2. On failed installation:
    • Error is now properly detected and logged
    • Clear error message shown to user with exit code
    • Commands are NOT registered (generator is required for commands to work)
    • User can troubleshoot based on error message

Fixes microsoft/powerplatform-vscode#1338

Original prompt

This section details on the original issue you should resolve

<issue_title>All Powerpages commands such as 'microsoft-powerapps-portals.webpage' not Registered during installation on UsGov systems</issue_title> <issue_description>When installing the Power Platform Tools extension on VS Code on a stricter system, commands for working with Power Pages Actions such as creating a new webpage or content snipper all give the same error that the command is not found. Appears that the commands are not registered in the command palette during installation. Tried uninstalling/reinstalling extension and VSCode.

Power Pages generator keeps showing installing v1.21.19

Microsoft PowerPlatform CLI Version: 1.49.4+g406813e (.NET Framework 4.8.9310.0)

npm: '11.6.0', node: '24.9.0'</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes microsoft/powerplatform-vscode#1338


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Oct 15 '25 05:10 Copilot