[BUG] TypeError in Playwright MCP browser_install Tool

Resolved 💬 3 comments Opened Aug 2, 2025 by chris-jackson-actionqa Closed Jan 3, 2026

Bug Report: TypeError in Playwright MCP browser_install Tool

Issue Description

When using the Playwright MCP server's browser_install tool, the following error occurs:

TypeError: (intermediate value).resolve is not a function

This error prevents the browser installation process from completing successfully and blocks the use of browser automation features in the MCP server.

Environment Information

  • Operating System: macOS
  • Node.js Version: v18.16.0
  • Package: @playwright/mcp@latest
  • Installation Method: Installed via Windsurf MCP configuration
  • Date Reported: August 1, 2025

Reproduction Steps

  1. Set up an MCP server configuration using @playwright/mcp:

``json
{
"mcpServers": {
"mcp-playwright": {
"command": "npx",
"args": [
"-y",
"@playwright/mcp@latest"
],
"env": {}
}
}
}
``

  1. Attempt to use the browser_install tool:

``javascript
// This would be called through the MCP interface
mcp4_browser_install();
``

  1. Observe the error:

``
TypeError: (intermediate value).resolve is not a function
``

Error Analysis

After investigating the source code, we identified that the error occurs in the Promise handling code within the install.js file. The issue is related to how Promise resolution is handled in the child process event listeners.

Location of the Issue

The error occurs in the following file:

/Users/chrijac2/.npm/_npx/9833c18b2d85bc59/node_modules/@playwright/mcp/lib/tools/install.js

Problematic Code

await new Promise((resolve, reject) => {
    child.on('close', code => {
        if (code === 0)
            resolve();
        else
            reject(new Error(`Failed to install browser: ${output.join('')}`));
    });
});

The issue appears to be related to how the resolve and reject callbacks are being used. In certain contexts, these callbacks might be losing their proper binding or being treated as non-function objects.

Attempted Fix

We attempted to fix the issue by modifying the Promise handling code to use the Promise.resolve() pattern instead of directly calling resolve and reject. Here's our attempted fix:

// FIX: Proper Promise handling with explicit checks for null/undefined
await new Promise((resolvePromise, rejectPromise) => {
    // Make sure child exists and is a valid process before attaching events
    if (!child) {
        rejectPromise(new Error('Failed to start browser installation process'));
        return;
    }
    
    child.on('close', code => {
        if (code === 0) {
            // Use Promise.resolve() pattern instead of directly calling resolve
            Promise.resolve().then(() => resolvePromise());
        } else {
            // Use Promise.reject() pattern for consistency
            Promise.resolve().then(() => 
                rejectPromise(new Error(`Failed to install browser: ${output.join('')}`))
            );
        }
    });
    
    // Add error handler to catch any process errors
    child.on('error', (err) => {
        Promise.resolve().then(() => 
            rejectPromise(new Error(`Error during browser installation: ${err.message}`))
        );
    });
});

Additional Changes

We also added:

  1. A try-catch block around the entire function
  2. Explicit error handling for the child process
  3. Null checks for the child process
  4. Additional error logging

Results of Fix Attempt

Despite applying the fix to the identified file, we continued to encounter the same error. This suggests that:

  1. The error might be occurring in a different file that uses similar Promise handling patterns
  2. The MCP server might be running from a different cache location than the one we modified
  3. There might be multiple instances of the same issue in the codebase

Workaround

As a workaround, we've installed Playwright browsers directly using:

npx playwright install

This allows us to use browser automation features without relying on the problematic browser_install tool.

Recommendations for Maintainers

  1. Review Promise Handling: Review all Promise handling code in the MCP server implementation, particularly in event handlers and child process interactions.
  1. Add Defensive Programming: Implement additional checks to ensure that resolve and reject callbacks are valid functions before attempting to call them.
  1. Improve Error Handling: Add more comprehensive error handling throughout the codebase to provide clearer error messages when issues occur.
  1. Consider Alternative Patterns: Instead of using the raw Promise constructor, consider using higher-level abstractions or utilities like util.promisify for child process operations.

Additional Information

We've created a test environment to reproduce and debug this issue at:

/Users/chrijac2/Documents/mcp-research/playwright-test/

This directory contains:

  • Test scripts to reproduce the error
  • A fixed version of the install.js file
  • Documentation on our debugging process

Contact Information

Please feel free to contact us for any additional information or clarification needed to resolve this issue.

---

Thank you for your attention to this bug report. We're happy to provide any additional information or testing to help resolve this issue.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗