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

[Question]: PlaywrightException: Process exited #1649

Closed
johnnyhegagng opened this issue Aug 2, 2021 · 12 comments
Closed

[Question]: PlaywrightException: Process exited #1649

johnnyhegagng opened this issue Aug 2, 2021 · 12 comments
Labels

Comments

@johnnyhegagng
Copy link

johnnyhegagng commented Aug 2, 2021

Your question

Hi,

I encountered a problem when deploying microsoft.playwright to the test server,it's called Playwright.CreateAsync() method, but my local working fine.

Microsoft.Playwright.PlaywrightException: Process exited
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Playwright.Transport.Connection.d__22`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Playwright.Playwright.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

@avodovnik
Copy link
Contributor

avodovnik commented Aug 2, 2021

To help you, we'll need a lot more details. Please consider filing a bug using the correct issue template, or add details:

  • version of Playwright for .NET you're using
  • OS & Version
  • deployment method
  • debug logs
  • code snippets

@johnnyhegagng
Copy link
Author

Hi @avodovnik,

the version of Playwright for .NET is: 1.13.0.0;

the OS & Version is: Windows Server 2016 Datacenter;

the deployment method is:
The application runs ASP.NET MVC 5 on .NET Framework 4.8
The project file includes a manual reference to the buildTransitive\Microsoft.Playwright.targets file from the NuGet package, since this isn't referenced automatically when not using
The application is deployed to an IIS site using Web Deploy
The application has assembly shadow copying disabled with in Web.config
The application sets the PLAYWRIGHT_BROWSERS_PATH environment variable to a path outside of the application directory that the app pool user has Full Control permissions for;

The error occurred when the “Playwright.CreateAsync“ method was called;

code snippets as follow:

using (var playwright = await Playwright.CreateAsync())
{
var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();

                        IConsoleMessage message = await page.RunAndWaitForConsoleMessageAsync(
                            () =>
                            {
                                return page.GotoAsync($"{m_Host}/report/reportemail/webreport?token={token}",
                                                         new PageGotoOptions()
                                                         {
                                                             Timeout = timeOutPlaywright
                                                         });
                            },
                            new PageRunAndWaitForConsoleMessageOptions
                            {
                                Predicate = (m) =>
                                {
                                    return funcRenderCompleted(m);
                                },
                                Timeout = timeOutPlaywright
                            }
                        );
                        if (message != null && funcRenderCompleted(message))
                        {
                            filePath = Path.Combine(ReportTempFolder, string.Format("{0}_{1}.png", fileName, DateTime.Now.ToString("yyyyMMddhhmmss")));

                            await page.ScreenshotAsync(new PageScreenshotOptions
                            {
                                Path = filePath,
                                FullPage = true
                            });
                        }
                    }

the debug logs as follow:

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Playwright.Transport.Connection.d__22`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Playwright.Playwright.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at xxxxxxx.TRReport.SendReport.d__8.MoveNext() in D:\a\1\s\xxxxxxxV5.2\branches\BugFixing\xxxxxxx.Service\DomainService\Reporting\Implement\Assist\SendReport.cs:line 218

@avodovnik
Copy link
Contributor

Hi @avodovnik,

the version of Playwright for .NET is: 1.13.0.0;

the OS & Version is: Windows Server 2016 Datacenter;

the deployment method is:
The application runs ASP.NET MVC 5 on .NET Framework 4.8
The project file includes a manual reference to the buildTransitive\Microsoft.Playwright.targets file from the NuGet package, since this isn't referenced automatically when not using
The application is deployed to an IIS site using Web Deploy
The application has assembly shadow copying disabled with in Web.config
The application sets the PLAYWRIGHT_BROWSERS_PATH environment variable to a path outside of the application directory that the app pool user has Full Control permissions for;

The error occurred when the “Playwright.CreateAsync“ method was called;

code snippets as follow:

using (var playwright = await Playwright.CreateAsync())
{
var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();

                        IConsoleMessage message = await page.RunAndWaitForConsoleMessageAsync(
                            () =>
                            {
                                return page.GotoAsync($"{m_Host}/report/reportemail/webreport?token={token}",
                                                         new PageGotoOptions()
                                                         {
                                                             Timeout = timeOutPlaywright
                                                         });
                            },
                            new PageRunAndWaitForConsoleMessageOptions
                            {
                                Predicate = (m) =>
                                {
                                    return funcRenderCompleted(m);
                                },
                                Timeout = timeOutPlaywright
                            }
                        );
                        if (message != null && funcRenderCompleted(message))
                        {
                            filePath = Path.Combine(ReportTempFolder, string.Format("{0}_{1}.png", fileName, DateTime.Now.ToString("yyyyMMddhhmmss")));

                            await page.ScreenshotAsync(new PageScreenshotOptions
                            {
                                Path = filePath,
                                FullPage = true
                            });
                        }
                    }

the debug logs as follow:

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Playwright.Transport.Connection.d__22`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Playwright.Playwright.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at xxxxxxx.TRReport.SendReport.d__8.MoveNext() in D:\a\1\s\xxxxxxxV5.2\branches\BugFixing\xxxxxxx.Service\DomainService\Reporting\Implement\Assist\SendReport.cs:line 218

Thanks.

Do you ensure you run playwright install on the deployment target?

@MC-DS
Copy link

MC-DS commented Aug 11, 2021

@avodovnik I'm a colleague of @johnnyhegagng, playwright install chromium is run during the deployment process with the PLAYWRIGHT_BROWSERS_PATH environment variable set to the same value as it is in the application itself. The directory that PLAYWRIGHT_BROWSERS_PATH points to has .links, chromium-901522 and ffmpeg-1005 directories inside of it.

@avodovnik
Copy link
Contributor

To clarify, you run the install command on the target server correct? Not copy/deploy the browsers folder over via WebDeploy?

@MC-DS
Copy link

MC-DS commented Aug 11, 2021

Both the Web Deploy process and the install command are run on the target server, by an Azure Pipelines agent running on the server.

@MC-DS
Copy link

MC-DS commented Aug 11, 2021

I managed to redirect the application process's stderr to a file, and got this output:

internal/fs/utils.js:269
    throw err;
    ^

Error: EPERM: operation not permitted, lstat 'E:\'
    at Object.realpathSync (fs.js:1604:5)
    at toRealPath (internal/modules/cjs/loader.js:336:13)
    at Function.Module._findPath (internal/modules/cjs/loader.js:492:22)
    at resolveMainPath (internal/modules/run_main.js:12:25)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:54:24)
    at internal/main/run_main_module.js:17:47 {
  errno: -4048,
  syscall: 'lstat',
  code: 'EPERM',
  path: 'E:\\'
}

It looks like this is probably the same issue as nodejs/node-v0.x-archive#3977, the app pool user has permission to access the application directory, but not any of the ancestor directories.

It's not directly related, but it would be nice if there was a better way to get the Playwright logs for non-console applications than writing stderr to a file.

@avodovnik
Copy link
Contributor

@JoelEinbinder could you have a look at this?

@MC-DS
Copy link

MC-DS commented Aug 11, 2021

It seems that just granting "Read Attributes" permission may not be enough if there are also Deny permissions in place, see nodejs/node#35853 and libuv/libuv#3267.

@MC-DS
Copy link

MC-DS commented Aug 12, 2021

We managed to fix this issue by removing the Deny Full Control permission for BUILTIN\IIS_IUSRS from the E: drive root and adding Allow Read Attributes permissions for the individual app pool identities to the ancestor directories (including the drive root), with inheritance disabled. The app pool identities don't have any other Allow permissions for the drive root, so they don't have any access except reading attributes.

Even with the Deny permission in place, the Effective Access tab of the folder security settings showed that the app pool had Read Attributes permission for the folder; despite Node being blocked from reading the attributes.

@avodovnik
Copy link
Contributor

Awesome to hear.

@avodovnik
Copy link
Contributor

Closing this as it seems like it was answered. Feel free to open another issue, if you still have problems doing this.

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

No branches or pull requests

3 participants