Skip to content
Closed
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
15 changes: 13 additions & 2 deletions packages/playwright-core/src/tools/dashboard/dashboardApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,12 @@ async function acquireSingleton(options: DashboardOptions): Promise<net.Server>

return await new Promise((resolve, reject) => {
const server = net.createServer();
server.listen(socketPath, () => resolve(server));
let listenRetries = 0;

const tryListen = () => {
server.listen(socketPath, () => resolve(server));
};

server.on('error', (err: NodeJS.ErrnoException) => {
const isInUse = err.code === 'EADDRINUSE'
|| (process.platform === 'win32' && err.code === 'EBUSY');
Expand All @@ -291,9 +296,15 @@ async function acquireSingleton(options: DashboardOptions): Promise<net.Server>
client.on('error', () => {
if (process.platform !== 'win32')
fs.unlinkSync(socketPath);
server.listen(socketPath, () => resolve(server));
// On Windows the previous server may still be shutting down; retry with backoff.
if (listenRetries >= 5)
return reject(err);
const delay = Math.min(100 * (1 << listenRetries++), 3000);
setTimeout(tryListen, delay);
});
});

tryListen();
});
}

Expand Down
Loading