playwright: [BUG] Cannot run Playwright via shell from IIS

Context:

  • Playwright Version: 1.8.0
  • Operating System: Windows
  • Node.js version: 12.18.3
  • Browser: Chromium
  • Extra: IIS 8

Code Snippet

const playwright = require('playwright');

(async () => {
  const browser = await playwright.chromium.launch();
  // ...
})();

Describe the bug

In IIS 8, I’m shelling out from PHP to run “node index.js”, but I’m getting the below fatal error.

It looks like an issue related to DPAPI, so I tried setting IIS to load a user profile, but that didn’t make a difference. I’ve read through the Chromium source code a bit, but I’m not sure how the problem traces back.

It’s worth noting that replacing Playwright with Puppeteer solved the problem. Puppeteer has no problem. It looks like Playwright uses a newer version of Chromium than Puppeteer, so that may be related, or it may be that Playwright is enabling/disabling a switch that Puppeteer doesn’t.

ERROR: Access denied
(node:8524) UnhandledPromiseRejectionWarning: browserType.launch: Protocol error (Browser.getVersion): Browser closed.
==================== Browser output: ====================
<launching> C:\\opt\\playwright\\node_modules\\playwright\\.local-browsers\\chromium-844399\\chrome-win\\chrome.exe --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=TranslateUI,BlinkGenPropertyTrees,ImprovedCookieControls,SameSiteByDefaultCookies,LazyFrameLoading --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --user-data-dir=C:\\Windows\\TEMP\\playwright_chromiumdev_profile-bamqjN --remote-debugging-pipe --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --no-startup-window
<launched> pid=5504
[err] [0128/124939.752:ERROR:os_crypt_win.cc(70)] Failed to encrypt: The system cannot find the file specified. (0x2)
[err] [0128/124939.752:FATAL:headless_browser_main_parts.cc(103)] Check failed: OSCrypt::Init(local_state_.get()). 
[err] Backtrace:
[err] 	IsSandboxedProcess [0x000007FE6F5B6362+709650]
[err] 	IsSandboxedProcess [0x000007FE6F5392F2+197538]
[err] 	IsSandboxedProcess [0x000007FE6F548468+259352]
[err] 	IsSandboxedProcess [0x000007FE6F5493A0+263248]
[err] 	RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x000007FE70C63F93+11967571]
[err] 	RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x000007FE70C63CFD+11966909]
[err] 	ovly_debug_event [0x000007FE6DB44DB9+15214521]
[err] 	ovly_debug_event [0x000007FE6DF04CF7+19146487]
[err] 	ovly_debug_event [0x000007FE6DB43B05+15209733]
[err] 	ovly_debug_event [0x000007FE6DB4681E+15221278]
[err] 	IsSandboxedProcess [0x000007FE6FFFB7E7+11479191]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE6F4CEDF3+9454995]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE6F4CFC12+9458610]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE6F4CF88F+9457711]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE6F4CE77D+9453341]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE6F4CEAFA+9454234]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE6F508639+9690585]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE6F5084FB+9690267]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE6F5082F7+9689751]
[err] 	ChromeMain [0x000007FE6CCC1238+408]
[err] 	Ordinal0 [0x000007F6C1F426C8+9928]
[err] 	Ordinal0 [0x000007F6C1F41A41+6721]
[err] 	GetHandleVerifier [0x000007F6C2089222+898850]
[err] 	BaseThreadInitThunk [0x000007FE9E8C1652+26]
[err] 	RtlUserThreadStart [0x000007FEA10E91B1+33]
[err] 

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 28 (1 by maintainers)

Commits related to this issue

Most upvoted comments

I’d just like to say that I’ve installed 1.9.1 and it’s working as expected. Thanks @aslushnikov and everyone else who helped to make this happen.

Thanks, @aslushnikov . I’m excited. I’m trying to promote Playwright for use on some of my projects, so looking forward to switching back to it.

Filed upstream: https://bugs.chromium.org/p/chromium/issues/detail?id=1173214

Chromium friends promised to push a fix!

Provided you can install IIS, PHP, and Node.js, here’s the code that should reproduce the problem:

PHP:

<?php
$script = 'C:\opt\myapp\debug.js';
$pdf_file = 'C:\Windows\Temp\myapp.pdf';
$url = 'https://github.com/microsoft/playwright/issues/5197';
$command = "node " . escapeshellarg($script) . " $url " . escapeshellarg($pdf_file) . " 2>&1"; 
$output = shell_exec($command);
print $output;
?>

Node.js:

process.env.PLAYWRIGHT_BROWSERS_PATH = 0;
process.env.DEBUG = 'pw:api';
const playwright = require('playwright');
async function generate_pdf(){
    const browser = await playwright.chromium.launch();
    await browser.close();
}
generate_pdf();

Folks, this is an impressive investigation!

That ‘OSCrypt::Init(local_state_.get())’ was just added to Chromium about 1 week ago. It looks like @dgozman wrote that patch.

@minusdavid I guess you refer to the https://chromium-review.googlesource.com/c/chromium/src/+/2634681, but that was actually just a code move and should not have changed.

Do you think you can help me reproduce this locally on my win machine? Once we can reproduce, we’ll be able to fix it upstream.

I’ll appreciate if you can lead me to setup IIS with a minimal script that reproduces the problem!

I’m not sure if my issue is related, but it looks like having same nature. I’m not running it in IIS, but it is executed remotely by Powershell.

2021-01-28T08:14:31.8029200Z     browserType.launch: Protocol error (Browser.getVersion): Browser closed.
2021-01-28T08:14:31.8029695Z 
2021-01-28T08:14:31.8206717Z     ==================== Browser output: ====================
2021-01-28T08:14:31.8207178Z 
2021-01-28T08:14:31.8393041Z     <launching> C:\Users\TestAdmin\AppData\Local\ms-playwright\chromium-844399\chrome-win\chrome.exe --disable-backgrou
2021-01-28T08:14:31.8393366Z nd-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-
2021-01-28T08:14:31.8393476Z backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensio
2021-01-28T08:14:31.8393755Z ns-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=Transla
2021-01-28T08:14:31.8393896Z teUI,BlinkGenPropertyTrees,ImprovedCookieControls,SameSiteByDefaultCookies,LazyFrameLoading --disable-hang-monitor --di
2021-01-28T08:14:31.8394030Z sable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --di
2021-01-28T08:14:31.8394101Z sable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basi
2021-01-28T08:14:31.8394258Z c --use-mock-keychain --user-data-dir=C:\Users\TES***D~1\AppData\Local\Temp\playwright_chromiumdev_profile-WhBIPH --remo
2021-01-28T08:14:31.8395378Z te-debugging-pipe --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,p
2021-01-28T08:14:31.8395456Z rimaryPointerType=4,availablePointerTypes=4 --no-sandbox --proxy-server=http://127.0.0.1:59652 --no-startup-window
2021-01-28T08:14:31.8395503Z 
2021-01-28T08:14:31.8566632Z     <launched> pid=6364
2021-01-28T08:14:31.8566934Z 
2021-01-28T08:14:31.8758443Z     [err] [0128/091812.086:ERROR:os_crypt_win.cc(70)] Failed to encrypt: The requested operation cannot be completed. T
2021-01-28T08:14:31.8759275Z he computer must be trusted for delegation and the current user account must be configured to allow delegation. (0x8009
2021-01-28T08:14:31.8759553Z 0345)
2021-01-28T08:14:31.8759627Z 
2021-01-28T08:14:31.8928490Z     [err] [0128/091812.086:FA***L:headless_browser_main_parts.cc(103)] Check failed: OSCrypt::Init(local_state_.get()). 
2021-01-28T08:14:31.8929009Z 
2021-01-28T08:14:31.9089745Z     [err] Backtrace:
2021-01-28T08:14:31.9090200Z 
2021-01-28T08:14:31.9257797Z     [err] 	IsSandboxedProcess [0x00007FFB57A76362+709650]
2021-01-28T08:14:31.9258098Z 
2021-01-28T08:14:31.9427730Z     [err] 	IsSandboxedProcess [0x00007FFB579F92F2+197538]
2021-01-28T08:14:31.9428134Z 
2021-01-28T08:14:31.9593677Z     [err] 	IsSandboxedProcess [0x00007FFB57A08468+259352]
2021-01-28T08:14:31.9594234Z 
2021-01-28T08:14:31.9818414Z     [err] 	IsSandboxedProcess [0x00007FFB57A093A0+263248]
2021-01-28T08:14:31.9819255Z 
2021-01-28T08:14:32.0054889Z     [err] 	RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x00007FFB59123F93+11967571]
2021-01-28T08:14:32.0055173Z 
2021-01-28T08:14:32.0221733Z     [err] 	RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x00007FFB59123CFD+11966909]
2021-01-28T08:14:32.0222098Z 
2021-01-28T08:14:32.0399658Z     [err] 	ovly_debug_event [0x00007FFB56004DB9+15214521]
2021-01-28T08:14:32.0400197Z 
2021-01-28T08:14:32.0607526Z     [err] 	ovly_debug_event [0x00007FFB563C4CF7+19146487]
2021-01-28T08:14:32.0607824Z 
2021-01-28T08:14:32.0791589Z     [err] 	ovly_debug_event [0x00007FFB56003B05+15209733]
2021-01-28T08:14:32.0791820Z 
2021-01-28T08:14:32.0960487Z     [err] 	ovly_debug_event [0x00007FFB5600681E+15221278]
2021-01-28T08:14:32.0961512Z 
2021-01-28T08:14:32.1127694Z     [err] 	IsSandboxedProcess [0x00007FFB584BB7E7+11479191]
2021-01-28T08:14:32.1128253Z 
2021-01-28T08:14:32.1293468Z     [err] 	CrashForExceptionInNonABICompliantCodeRange [0x00007FFB5798EDF3+9454995]
2021-01-28T08:14:32.1293797Z 
2021-01-28T08:14:32.1476608Z     [err] 	CrashForExceptionInNonABICompliantCodeRange [0x00007FFB5798FC12+9458610]
2021-01-28T08:14:32.1477048Z 
2021-01-28T08:14:32.1639539Z     [err] 	CrashForExceptionInNonABICompliantCodeRange [0x00007FFB5798F88F+9457711]
2021-01-28T08:14:32.1641409Z 
2021-01-28T08:14:32.2436050Z     [err] 	CrashForExceptionInNonABICompliantCodeRange [0x00007FFB5798E77D+9453341]
2021-01-28T08:14:32.2436526Z 
2021-01-28T08:14:32.2609130Z     [err] 	CrashForExceptionInNonABICompliantCodeRange [0x00007FFB5798EAFA+9454234]
2021-01-28T08:14:32.2609649Z 
2021-01-28T08:14:32.2787184Z     [err] 	CrashForExceptionInNonABICompliantCodeRange [0x00007FFB579C8639+9690585]
2021-01-28T08:14:32.2787439Z 
2021-01-28T08:14:32.2950548Z     [err] 	CrashForExceptionInNonABICompliantCodeRange [0x00007FFB579C84FB+9690267]
2021-01-28T08:14:32.2951590Z 
2021-01-28T08:14:32.3171654Z     [err] 	CrashForExceptionInNonABICompliantCodeRange [0x00007FFB579C82F7+9689751]
2021-01-28T08:14:32.3173514Z 
2021-01-28T08:14:32.3399166Z     [err] 	ChromeMain [0x00007FFB55181238+408]
2021-01-28T08:14:32.3399815Z 
2021-01-28T08:14:32.3566979Z     [err] 	Ordinal0 [0x00007FF6474426C8+9928]
2021-01-28T08:14:32.3567407Z 
2021-01-28T08:14:32.3733782Z     [err] 	Ordinal0 [0x00007FF647441A41+6721]
2021-01-28T08:14:32.3734017Z 
2021-01-28T08:14:32.3926451Z     [err] 	GetHandleVerifier [0x00007FF647589222+898850]
2021-01-28T08:14:32.3927508Z 
2021-01-28T08:14:32.4111176Z     [err] 	BaseThreadInitThunk [0x00007FFB871B7034+20]
2021-01-28T08:14:32.4150545Z 
2021-01-28T08:14:32.4300685Z     [err] 	RtlUserThreadStart [0x00007FFB8909D0D1+33]
2021-01-28T08:14:32.4301851Z 
2021-01-28T08:14:32.4467068Z     [err] 

It started to happen on the new PW1.8.0, switching back to 1.6.2 solves the problem.

My user TestAdmin is a domain administrator, and has full access permissions.