Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions packages/browser-playwright/src/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,21 @@ export class PlaywrightBrowserProvider implements BrowserProvider {
}

// make sure the traces are finished if the test hangs
process.on('SIGTERM', () => {
if (!this.browser) {
return
}
const promises = []
for (const [trace, contextId] of this.pendingTraces.entries()) {
promises.push((() => {
const context = this.contexts.get(contextId)
return context?.tracing.stopChunk({ path: trace })
})())
}
return Promise.allSettled(promises)
})
process.on('SIGTERM', this.onSIGTERM)
}

private onSIGTERM = () => {
if (!this.browser) {
return
}
const promises = []
for (const [trace, contextId] of this.pendingTraces.entries()) {
promises.push((() => {
const context = this.contexts.get(contextId)
return context?.tracing.stopChunk({ path: trace })
})())
}
return Promise.allSettled(promises)
}

private async openBrowser(openBrowserOptions: { parallel: boolean }) {
Expand Down Expand Up @@ -545,6 +547,8 @@ export class PlaywrightBrowserProvider implements BrowserProvider {
}

async close(): Promise<void> {
process.off('SIGTERM', this.onSIGTERM)

debug?.('[%s] closing provider', this.browserName)
this.closing = true
if (this.browserPromise) {
Expand Down
Loading