playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[BUG] Playwright sometimes generates trace files that can't be opened

Open thnk2wn opened this issue 1 year ago • 6 comments

Playwright seems to generate some corrupted trace files at times that can't be opened in the Trace Viewer.

I can't quite figure out the pattern but have noticed at times the first failure trace can't be opened but later retry traces can be opened. Also it seems it may possibly be more related to flaky tests but not sure without more time.

System info

  • Playwright Version: 1.33.0
  • Operating System: Ubuntu 20
  • Browser: Chromium

Sample Bad Trace Files

1a2ae58c7387c65d4f4f5519ddedf24fc201ed5e.zip

trace.zip

Steps

  • Run tests via CI/CD
  • Inspect traces of failed tests

Expected

Can open trace at https://trace.playwright.dev/

Actual

Could not load trace from 1a2ae58c7387c65d4f4f5519ddedf24fc201ed5e.zip. Make sure to upload a valid Playwright trace.

thnk2wn avatar May 20 '23 14:05 thnk2wn

@thnk2wn These traces are indeed corrupted. Unfortunately, we are not sure how this happened, so any repro would be very helpful. Even if it only reproduces sometimes.

dgozman avatar May 23 '23 23:05 dgozman

@dgozman This is an internal app and a private repo so I can't share them directly. Copying and redacting and setting up in new public repo(s) would likely be a lot of work but could consider that later.

In the mean time are there certain details I could provide that might help?

thnk2wn avatar May 24 '23 13:05 thnk2wn

@thnk2wn Could you please try upgrading to @playwright/[email protected]? There have been tracing changes between 1.33 and 1.34, so it might be that the issue has been already fixed?

dgozman avatar May 24 '23 17:05 dgozman

@dgozman Thanks. Done. We're not getting any failing tests at the moment so I don't have any traces to look at. I can look at turning on trace for success later and testing but out on vacation for 10 days now.

thnk2wn avatar May 24 '23 19:05 thnk2wn

Same Issue, I see this, updating playwright did not work

Screenshot 2023-05-25 at 16 59 43

17Amir17 avatar May 25 '23 14:05 17Amir17

@17Amir17 Any chance you could share a repro that produces corrupted traces?

dgozman avatar May 25 '23 14:05 dgozman

Closing as part of the triage process since it seemed stale. Please create a new issue with a detailed reproducible or feature request if you still face issues.

mxschmitt avatar Jun 02 '23 19:06 mxschmitt

unable to open traces.zip file in playwright 1.39. my file is: data/a6c572a0814a8ad11aea084ffd7f3306eaf0c55d.zip.

subhaprakash avatar Nov 29 '23 07:11 subhaprakash

Still getting this with version 1.40, is this a known issue? I try to upload the trace file and get the above error. I tried unzipping the trace file and same occurs

FYI but the trace file is generated by the Playwright lib (not playwright test):

  await context.tracing.start({ screenshots: true, snapshots: true });
  await context.tracing.stop({ path: 'test-results/traces/trace_'+scenarioName+'_'+timeStamp+'.zip' });

LANDG-MartinP avatar Dec 20 '23 10:12 LANDG-MartinP

I was also getting corrupted trace zip files that couldn't be extracted and wouldn't load into the Playwright Trace viewer. It would only create valid zip files when debugging, likely because stepping through the code gave it time to write correctly.

It turned out I was incorrectly using the following NUnit TearDown method without await:

    [TearDown]
    public Task TearDown()
    {
        Context.Tracing.StopAsync(new TracingStopOptions
        {
            Path = $"traces/{DateTime.Now:yyyyMMdd_HHmmss.fff}.zip",
        });
    }

When I changed it to async, it works every time even when not debugging:

    [TearDown]
    public async Task TearDownAsync()
    {
        await Context.Tracing.StopAsync(new TracingStopOptions
        {
            Path = $"traces/{DateTime.Now:yyyyMMdd_HHmmss.fff}.zip",
        });
    }

mrobinson-campion avatar Feb 21 '24 00:02 mrobinson-campion