const FIREBASE_API_KEY = 'AIzaSyCZsz4v9a9ioF5uhK2bACy8xea6iIhSZCQ'; const SERVER_URL = 'https://hari7775-resume-server.hf.space'; async function run() { console.log('1. Starting massive 100-job stress test to fill server queue backlog...'); // Pre-generate tokens in batches of 10 console.log('Generating 100 Firebase tokens...'); const tokens = []; for (let b = 0; b < 10; b++) { const authBatch = Array.from({ length: 10 }).map(() => fetch(`https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${FIREBASE_API_KEY}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ returnSecureToken: true }) }).then(r => r.json()).then(d => d.idToken) ); const resolved = await Promise.all(authBatch); tokens.push(...resolved); } console.log(`ā ${tokens.length} tokens ready!`); console.log('\nš Dispatching 100 heavy PDF generation requests to server...'); const jobs = tokens.map((token, idx) => { const i = idx + 1; const html = `
Testing sustained backlog position # under 100 concurrent job load.
`; return fetch(`${SERVER_URL}/api/export-pdf`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }, body: JSON.stringify({ html, metadata: { filename: `massive_load_${i}` } }) }).then(r => r.json()).then(d => { if (i % 10 === 0 || i <= 5) { console.log(`[Job #${i}/100] Server Queue Position: #${d.position} (ID: ${d.jobId?.slice(0, 8)})`); } return d; }).catch(e => { console.error(`Job #${i} error:`, e.message); }); }); console.log('\nš„ 100 requests DISPATCHED! The server queue backlog will stay active for ~1-2 minutes! Click Export PDF in your browser now!'); await Promise.all(jobs); console.log('\nā All 100 jobs finished processing!'); } run();