TimeoutError
Thrown when an operation takes longer than the configured timeout.
Import
import { TimeoutError } from '@activade/droid-sdk';
Properties
timeoutMs
readonly timeoutMs: number
The timeout value in milliseconds that was exceeded.
Usage
try {
await droid.exec('Complex long-running task');
} catch (error) {
if (error instanceof TimeoutError) {
console.error(`Timed out after ${error.timeoutMs}ms`);
}
}
Preventing Timeouts
Increase Timeout
const droid = new Droid({
timeout: 600000 // 10 minutes
});
Per-execution Timeout
// Use a longer timeout for specific operations
const result = await droid.exec('Build entire project', {
timeout: 900000 // 15 minutes
});
Handling Timeouts Gracefully
async function executeWithFallback(prompt: string) {
const droid = new Droid({ timeout: 60000 });
try {
return await droid.exec(prompt);
} catch (error) {
if (error instanceof TimeoutError) {
console.log('Operation timed out, trying with streaming...');
// Fall back to streaming for progress visibility
const thread = droid.startThread();
const { events, result } = await thread.runStreamed(prompt);
for await (const event of events) {
console.log('Progress:', event.type);
}
return await result;
}
throw error;
}
}
Default Timeout
The default timeout is 600000ms (10 minutes). For complex operations, consider:
- Breaking into smaller tasks
- Using streaming for progress visibility
- Increasing the timeout value