You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Close Context leaves the context open when stopping the trace or saving coverage fails #5322
Describe the bug closeContext in node/playwright-wrapper/playwright-state.ts stops tracing and saves the coverage reports before it closes the context:
If tracing.stop or _saveCoverageReport throws, the context is not closed and stays on the context stack. For a persistent context, the browser without a browser object is not closed either.
This affects Close Context and the automatic closing of contexts at the end of a test or suite, which use closeContext. Close Browser is not affected: BrowserState.close() stops tracing and closes each context inside one try.
The bug is older than #5318. After #5318 it also affects adopted contexts: adoptContext's onClose runs when the browser of the context closes, so when the context is closed with Close Context or automatically and stopping the trace or saving coverage fails, onClose does not run either. #5318 put closing the context and the browser in try/finally, but not the two steps before it.
Expected behavior
The context is closed and removed from the stack, the browser of a persistent or adopted context is closed, and onClose runs, even when stopping the trace or saving coverage fails. The failure is still reported.
Possible fix
Move stopping the trace and saving coverage inside the try in closeContext, or give them their own try/finally around closing the context.
Activity