-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-test2.js
More file actions
29 lines (24 loc) · 1.05 KB
/
Copy pathdebug-test2.js
File metadata and controls
29 lines (24 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const https = require('https');
const GATEWAY = 'gateway-production-1340.up.railway.app';
function fetch(path) {
return new Promise((resolve) => {
const start = Date.now();
const req = https.get({ hostname: GATEWAY, path, port: 443, rejectUnauthorized: false }, (res) => {
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => resolve({ status: res.statusCode, dur: Date.now() - start, body: data.substring(0, 200) }));
});
req.on('error', (err) => resolve({ status: 0, dur: Date.now() - start, body: err.message }));
req.setTimeout(10000, () => { req.destroy(); resolve({ status: 0, dur: 10000, body: 'timeout' }); });
});
}
async function main() {
// First, wait 1s to let any previous rate limit windows expire
await new Promise(r => setTimeout(r, 1000));
for (let i = 0; i < 5; i++) {
const r = await fetch('/readyz');
console.log(`Request ${i+1}: status=${r.status} dur=${r.dur}ms body=${r.body}`);
await new Promise(r => setTimeout(r, 100));
}
}
main().catch(console.error);