increase frontend additional time-to-start time to 3 secs because windows is slow, better handling of rate limiting tunnel errors

This commit is contained in:
Egor 2025-12-03 18:03:31 -08:00
parent 80bb6d5e97
commit 6561e2dd09
2 changed files with 15 additions and 7 deletions

View file

@ -66,7 +66,7 @@ export const App = () => {
setTimeout(() => { setTimeout(() => {
setIsServerReady(true); setIsServerReady(true);
setActiveInterfaceTab(defaultInterfaceTab); setActiveInterfaceTab(defaultInterfaceTab);
}, 1000); }, 3000);
}); });
return cleanup; return cleanup;

View file

@ -38,15 +38,23 @@ export const startTunnel = async (
} }
const tunnelTarget = getTunnelTarget(frontendPreference); const tunnelTarget = getTunnelTarget(frontendPreference);
const tunnel = Tunnel.quick(tunnelTarget, { const tunnel = Tunnel.quick(tunnelTarget, { '--no-autoupdate': true });
'--no-autoupdate': true,
});
activeTunnel = tunnel; activeTunnel = tunnel;
let rateLimited = false;
tunnel.on('stderr', (data: string) => {
if (data.includes('429') || data.includes('Too Many Requests')) {
rateLimited = true;
}
});
const url = await new Promise<string>((resolve, reject) => { const url = await new Promise<string>((resolve, reject) => {
const timeout = setTimeout(() => { const timeout = setTimeout(() => {
reject(new Error('Tunnel connection timed out')); const message = rateLimited
? 'Cloudflare rate limit exceeded. Please wait a few minutes and try again.'
: 'Tunnel connection timed out';
reject(new Error(message));
}, 30000); }, 30000);
tunnel.once('url', (url) => { tunnel.once('url', (url) => {
@ -64,7 +72,7 @@ export const startTunnel = async (
sendKoboldOutput(`Tunnel ready at ${tunnelUrl}`); sendKoboldOutput(`Tunnel ready at ${tunnelUrl}`);
sendToRenderer('tunnel-url-changed', tunnelUrl); sendToRenderer('tunnel-url-changed', tunnelUrl);
tunnel.on('error', (error) => { tunnel.on('error', (error: Error) => {
logError(`Tunnel error: ${error.message}`, error); logError(`Tunnel error: ${error.message}`, error);
sendKoboldOutput(`Tunnel error: ${error.message}`); sendKoboldOutput(`Tunnel error: ${error.message}`);
}); });