Skip to content
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

[BUG] Cannot run Playwright via shell from IIS #5197

Closed
minusdavid opened this issue Jan 28, 2021 · 28 comments · Fixed by #5434
Closed

[BUG] Cannot run Playwright via shell from IIS #5197

minusdavid opened this issue Jan 28, 2021 · 28 comments · Fixed by #5434

Comments

@minusdavid
Copy link

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] 
@aslushnikov
Copy link
Collaborator

@minusdavid I remember there were some user permissions that have to be configured in IIS. In this case, it looks like the user that runs the service has very limited access, so subprocess can't do much. As a result, launched Chromium cannot access libraries required for its operations.

Here's some documentation regarding this: https://docs.microsoft.com/en-us/troubleshoot/windows-server/backup-and-storage/access-denied-run-batch-job

+cc @kblok in case Darío happens to know more about this

@minusdavid
Copy link
Author

Thanks @aslushnikov but it's not clear what needs the permissions.

If I shell out to launch chrome.exe itself (with minimal parameters in headless mode), I have no problems. If I shell out to launch Puppeteer, I have no problems. It's just Playwright. All with the same IIS user.

So I figure Playwright must be activating some functionality in Chrome which needs higher permissions. I'm not very familiar with the Chromium codebase, but my guess is that Playwright is activating some security mechanism - or the newer version of Chromium (v90) it uses has higher security requirements than the one used by Puppeteer (v88) and the vanilla Chrome (I can't recall the version but it'll be high 80s).

@creage
Copy link

creage commented Jan 28, 2021

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.

@minusdavid
Copy link
Author

Oh that's really interesting @creage!

@creage
Copy link

creage commented Jan 28, 2021

I found an interesting solution, that might work - I'm about to try it out.

https://dba.stackexchange.com/questions/178325/the-computer-must-be-trusted-for-delegation-and-the-current-user-account-must

UPDATE: no, this didn't work

@minusdavid
Copy link
Author

In my case, I looked at line 70 of https://chromium.googlesource.com/chromium/src/+/master/components/os_crypt/os_crypt_win.cc, which got me looking at DPAPI.

Then my Googling led me to https://blog.dotsmart.net/2011/01/26/solved-windows-identity-foundation-the-system-cannot-find-the-file-specified/ but changing "Load User Profile" to true didn't really make a difference.

https://bugs.chromium.org/p/chromium/issues/detail?id=1000799 makes me think that DPAPI is being used for encrypting cookies?

Yet I don't have the problem with Puppeteer or chrome.exe directly...

@minusdavid
Copy link
Author

Guessing that this is the right documentation for CryptProtectData...

https://docs.microsoft.com/en-us/windows/win32/api/dpapi/nf-dpapi-cryptprotectdata

This part is interesting: "Typically, only a user with logon credentials that match those of the user who encrypted the data can decrypt the data."

My IIS user wouldn't have logon credentials...

Looking at https://security.stackexchange.com/questions/51779/securing-an-iis-application-with-a-complex-configuration, it talks about how my virtual user account will likely have troubles unless I switch to the "NetworkService" identity or use "LoadUserProfile" (although they're skeptical about the latter and I've had no luck with the latter anyway...)

...but... this doesn't explain why it works with Puppeteer and Chrome and not Playwright...

@minusdavid
Copy link
Author

I should've looked more closely at that stack trace.

That 'OSCrypt::Init(local_state_.get())' was just added to Chromium about 1 week ago.

It looks like @dgozman wrote that patch.

@minusdavid
Copy link
Author

So that explains why it's only happening with Playwright. It's the only thing using a new enough Chromium to be a problem heh.

Maybe I'll play more with LoadUserProfile as per https://stackoverflow.com/questions/57061345/cryptprotectdata-fails-with-error-file-not-found-when-the-user-profile-is-not. Maybe I wasn't thorough enough in my experiments.

This might help as well...
https://docs.microsoft.com/en-us/archive/blogs/spatdsg/crypt-calls-failing

Trying to find the source code for CryptProtectData but I'm guessing it's closed source as all I can find is the API in dpapi.h and a not so helpful Wine implementation. @aslushnikov, you work at Microsoft now, yeah? Maybe you have a colleague who can comment more on the inner workings of that function?

@minusdavid
Copy link
Author

I don't have much time to spend playing on this one. Since it's working with Puppeteer, I'm just going to use that for the time being, but this really seems like a ticking time bomb. It'll catch out Puppeteer eventually too.

Of course, it seems like an issue with Chromium rather than Playwright at this point. I'll try to find some time to play with LoadUserProfile more and maybe Playwright could add some documentation about it if I get it working...

I suppose one thing Playwright might consider doing is dropping the version of Chromium used by Playwright, but that's a short-term solution too.

Anyone else have any other thoughts on this one? I'm going to call it a night.

@aslushnikov
Copy link
Collaborator

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!

@aslushnikov aslushnikov assigned aslushnikov and unassigned dgozman Jan 28, 2021
@minusdavid
Copy link
Author

Thanks, Andrey. Apologies for the stream-of-consciousness, but hopefully it was helpful.

Ooops, I thought that I had included the commit reference. I was looking at https://chromium.googlesource.com/chromium/src/+/4fbc172e7c66f520a630875ff68de5ff0c764428 but yeah that code review is for the one. I noticed it was a code move, but I was guessing that the code in headless_content_main_delegate.cc must be run later or in a child process or something like that.

Hmm, I can certainly try! I'll admit that I'm much more familiar with Linux and tend to use Docker containers for this type of scenario. I'm tempted to try "Windows Sandbox" to see if I can create a temporary reproducible Windows environment.

@minusdavid
Copy link
Author

Alas, there's seemingly no way of enabling "Internet Information Services" inside Windows Sandbox. That's a let down...

@minusdavid
Copy link
Author

On my Windows workstation, I use Docker Desktop and WSL 1, which are backed using Hyper-V. It looks like Hyper-V has an easy "Windows 10 dev environment" option.

It's a 18.30GB download, but I'm going to give that a go.

@minusdavid
Copy link
Author

Get Windows environment

  1. Open Hyper-V
  2. Click "Quick Create..."
  3. Choose "Windows 10 dev environment"
  4. Click "Create Virtual Machine"

Setup IIS

  1. Search for "Windows Features"
  2. Check the box next to "Internet Information Services"
  3. Search for "IIS" and open the IIIS Manager (this will be IIS 10)
  4. Copy C:\inetpub\wwwrooot to C:\inetpub\marketing

Install PHP

  1. Click "Get New Web Platform Components" on the far right side of the screen to open a web browser page
  2. Click "Install this extension" in the web browser
  3. Open the downloaded installer and run it
  4. Close IIS and re-open IIS
  5. Click "Web Platform Installer" under the Management heading
  6. Search for PHP
  7. Choose "PHP 7.1.29 (x86)" and click "Add"
  8. Click "Install"

And... it's failing to install. Probably because it's a dev image. I found this link to do it manually but I don't have the stamina to do it after a full work day (https://docs.microsoft.com/en-us/iis/application-frameworks/scenario-build-a-php-website-on-iis/configuring-step-1-install-iis-and-php#13-download-and-install-php-manually)

At the end of the day, all you need is IIS, PHP, and Node.js. You could probably substitute PHP for something else that can shell out.

@minusdavid
Copy link
Author

I've tried playing more with LoadUserProfile.

It actually broke things for Puppeteer until I changed the permissions for the user created*... but still broken for Playwright.

Changed from ApplicationPoolIdentity to NetworkService for the Application Pool, and now getting different permission issue.

*It seems that the ApplicationPoolIdentity is a virtual user based on the application pool name, but the site is actually set up to "Connect as" a real non-login system user. I could only get Puppeteer working with LoadUserProfile when I allowed the real user access to the C:\Users\TEMP folder created by Puppeteer as the virtual user.

@minusdavid
Copy link
Author

Even when I'm using pass through authentication and the default application pool, I get the same issue. Here's the full log:


2021-01-29T08:52:39.483Z pw:api => browserType.launch started
ERROR: The process "6728" not found.
2021-01-29T08:52:39.967Z pw:api <= browserType.launch failed
(node:5028) UnhandledPromiseRejectionWarning: browserType.launch: Protocol error (Browser.getVersion): Browser closed.
==================== Browser output: ====================
<launching> C:\opt\myapp_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-EGTpID --remote-debugging-pipe --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --password-store=detect --no-startup-window
<launched> pid=6728
[err] [0129/195239.639:ERROR:os_crypt_win.cc(70)] Failed to encrypt: The system cannot find the file specified. (0x2)
[err] [0129/195239.639:FATAL:headless_browser_main_parts.cc(103)] Check failed: OSCrypt::Init(local_state_.get()). 
[err] Backtrace:
[err] 	IsSandboxedProcess [0x000007FE69C36362+709650]
[err] 	IsSandboxedProcess [0x000007FE69BB92F2+197538]
[err] 	IsSandboxedProcess [0x000007FE69BC8468+259352]
[err] 	IsSandboxedProcess [0x000007FE69BC93A0+263248]
[err] 	RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x000007FE6B2E3F93+11967571]
[err] 	RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x000007FE6B2E3CFD+11966909]
[err] 	ovly_debug_event [0x000007FE681C4DB9+15214521]
[err] 	ovly_debug_event [0x000007FE68584CF7+19146487]
[err] 	ovly_debug_event [0x000007FE681C3B05+15209733]
[err] 	ovly_debug_event [0x000007FE681C681E+15221278]
[err] 	IsSandboxedProcess [0x000007FE6A67B7E7+11479191]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE69B4EDF3+9454995]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE69B4FC12+9458610]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE69B4F88F+9457711]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE69B4E77D+9453341]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE69B4EAFA+9454234]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE69B88639+9690585]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE69B884FB+9690267]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE69B882F7+9689751]
[err] 	ChromeMain [0x000007FE67341238+408]
[err] 	Ordinal0 [0x000007F6854E26C8+9928]
[err] 	Ordinal0 [0x000007F6854E1A41+6721]
[err] 	GetHandleVerifier [0x000007F685629222+898850]
[err] 	BaseThreadInitThunk [0x000007FE9E8C1652+26]
[err] 	RtlUserThreadStart [0x000007FEA10E91B1+33]
[err] 
=========================== logs ===========================
<launching> C:\opt\myapp_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-EGTpID --remote-debugging-pipe --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --password-store=detect --no-startup-window
<launched> pid=6728
[err] [0129/195239.639:ERROR:os_crypt_win.cc(70)] Failed to encrypt: The system cannot find the file specified. (0x2)
[err] [0129/195239.639:FATAL:headless_browser_main_parts.cc(103)] Check failed: OSCrypt::Init(local_state_.get()). 
[err] Backtrace:
[err] 	IsSandboxedProcess [0x000007FE69C36362+709650]
[err] 	IsSandboxedProcess [0x000007FE69BB92F2+197538]
[err] 	IsSandboxedProcess [0x000007FE69BC8468+259352]
[err] 	IsSandboxedProcess [0x000007FE69BC93A0+263248]
[err] 	RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x000007FE6B2E3F93+11967571]
[err] 	RelaunchChromeBrowserWithNewCommandLineIfNeeded [0x000007FE6B2E3CFD+11966909]
[err] 	ovly_debug_event [0x000007FE681C4DB9+15214521]
[err] 	ovly_debug_event [0x000007FE68584CF7+19146487]
[err] 	ovly_debug_event [0x000007FE681C3B05+15209733]
[err] 	ovly_debug_event [0x000007FE681C681E+15221278]
[err] 	IsSandboxedProcess [0x000007FE6A67B7E7+11479191]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE69B4EDF3+9454995]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE69B4FC12+9458610]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE69B4F88F+9457711]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE69B4E77D+9453341]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE69B4EAFA+9454234]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE69B88639+9690585]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE69B884FB+9690267]
[err] 	CrashForExceptionInNonABICompliantCodeRange [0x000007FE69B882F7+9689751]
[err] 	ChromeMain [0x000007FE67341238+408]
[err] 	Ordinal0 [0x000007F6854E26C8+9928]
[err] 	Ordinal0 [0x000007F6854E1A41+6721]
[err] 	GetHandleVerifier [0x000007F685629222+898850]
[err] 	BaseThreadInitThunk [0x000007FE9E8C1652+26]
[err] 	RtlUserThreadStart [0x000007FEA10E91B1+33]
[err] 
============================================================
Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs.
    at Connection.sendMessageToServer (C:\opt\myapp_playwright\node_modules\playwright\lib\client\connection.js:69:15)
    at Proxy.<anonymous> (C:\opt\myapp_playwright\node_modules\playwright\lib\client\channelOwner.js:44:61)
    at C:\opt\myapp_playwright\node_modules\playwright\lib\client\browserType.js:61:73
    at BrowserType._wrapApiCall (C:\opt\myapp_playwright\node_modules\playwright\lib\client\channelOwner.js:72:34)
    at BrowserType.launch (C:\opt\myapp_playwright\node_modules\playwright\lib\client\browserType.js:52:21)
    at Object.generate_pdf (C:\opt\myapp_playwright\lib\myapp.js:36:47)
    at Object.<anonymous> (C:\opt\myapp_playwright\index.js:35:30)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
(node:5028) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:5028) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@minusdavid
Copy link
Author

Anyway, worked way too much on this tonight...

@minusdavid
Copy link
Author

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();

@aslushnikov
Copy link
Collaborator

aslushnikov commented Feb 1, 2021

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

Chromium friends promised to push a fix!

@minusdavid
Copy link
Author

Thanks so much @aslushnikov ! You're a champion! (As are your Chromium friends!)

@minusdavid
Copy link
Author

Wow, the Chromium folk work fast!

They've already written, reviewed, and pushed a patch to master: https://chromium-review.googlesource.com/c/chromium/src/+/2665975

I don't think it's been added to a stable release yet. What's the process for updating Playwright's Chromium revision? It seems that Playwright stays quite current, so I imagine once there is a build available that you folk will then look at taking it up?

Really impressed with how quickly everything has gone. Once this issue is resolved, I reckon that I'll switch back to Playwright from Puppeteer :D.

@minusdavid
Copy link
Author

I'm not familiar with the Chrome build numbers but I see that patch in the 90.0.4408.0 version for Chromium. I'm guessing its available now?

@aslushnikov
Copy link
Collaborator

We'll roll Chromium soon'ish (in a few days), and the fix will be available at playwright@next. I'll let you know!

@minusdavid
Copy link
Author

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.

aslushnikov added a commit to aslushnikov/playwright that referenced this issue Feb 12, 2021
aslushnikov added a commit to aslushnikov/playwright that referenced this issue Feb 12, 2021
@minusdavid
Copy link
Author

I just tried updating playwright but still had the same problem, but I can see now that playwright 1.8.1 is still too old (7 days old).

I'm guessing this fix will be in playwright 1.8.2?

@mxschmitt
Copy link
Member

I just tried updating playwright but still had the same problem, but I can see now that playwright 1.8.1 is still too old (7 days old).

I'm guessing this fix will be in playwright 1.8.2?

npm install playwright@next should include your fix until stable gets released.

@minusdavid
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants