Skip to content

Commit fa82396

Browse files
feat: add ping polling for tunnel
1 parent ee5523a commit fa82396

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/tasks/createBuildExec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ListrTask, ListrRendererFactory } from 'listr2';
22
import { Context } from '../types.js'
33
import chalk from 'chalk';
44
import { updateLogContext } from '../lib/logger.js';
5-
import { startTunnelBinary, startPollingForTunnel, stopTunnelHelper } from '../lib/utils.js';
5+
import { startTunnelBinary, startPollingForTunnel, stopTunnelHelper, startPingPolling } from '../lib/utils.js';
66

77
export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRendererFactory> => {
88
return {
@@ -43,6 +43,7 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
4343
}
4444

4545
if (ctx.config.tunnel && ctx.config.tunnel?.type === 'auto') {
46+
startPingPolling(ctx);
4647
if (ctx.build && ctx.build.id) {
4748
startPollingForTunnel(ctx, '', false, '');
4849
}

src/tasks/finalizeBuild.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ListrTask, ListrRendererFactory } from 'listr2';
22
import { Context } from '../types.js'
33
import { updateLogContext } from '../lib/logger.js';
44
import chalk from 'chalk';
5-
import { startPolling } from '../lib/utils.js';
5+
import { startPolling, pingIntervalId } from '../lib/utils.js';
66
import { unlinkSync } from 'fs';
77
import constants from '../lib/constants.js';
88
import fs from 'fs';
@@ -27,6 +27,11 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
2727
}
2828
let buildUrls = `build url: ${ctx.build.url}\n`;
2929

30+
if (pingIntervalId !== null) {
31+
clearInterval(pingIntervalId);
32+
ctx.log.debug('Ping polling stopped immediately.');
33+
}
34+
3035
for (const [sessionId, capabilities] of ctx.sessionCapabilitiesMap.entries()) {
3136
try {
3237
const buildId = capabilities?.buildId || '';

0 commit comments

Comments
 (0)