• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cofacts / rumors-api / 13471431128

22 Feb 2025 08:57AM UTC coverage: 82.739% (-0.3%) from 83.059%
13471431128

Pull #362

github

web-flow
Merge c9fe272b9 into 51658aad9
Pull Request #362: Proxy read timeout mitigation

774 of 985 branches covered (78.58%)

Branch coverage included in aggregate %.

2 of 10 new or added lines in 2 files covered. (20.0%)

1498 of 1761 relevant lines covered (85.07%)

18.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

8.33
/src/timeoutHeader.ts
1
import type { Context, Next } from 'koa';
2

3
/**
4
 * Creates a middleware that sends a preliminary header after a timeout
5
 * to keep the connection alive with Cloudflare
6
 * @param {number} timeout Timeout in milliseconds before sending the header
7
 * @returns Koa middleware function
8
 */
9
export default function timeoutHeader(timeout = 30000) {
×
10
  return async (ctx: Context, next: Next): Promise<void> => {
1✔
11
    // Create a timer to send headers
NEW
12
    const timer = setTimeout(() => {
×
NEW
13
      if (!ctx.headerSent) {
×
NEW
14
        console.log(
×
15
          '[timeoutHeader] Sending preliminary header after',
16
          timeout,
17
          'ms'
18
        );
NEW
19
        ctx.set('Content-Encoding', 'identity');
×
NEW
20
        ctx.flushHeaders();
×
21
      }
22
    }, timeout);
23

NEW
24
    try {
×
NEW
25
      await next();
×
26
    } finally {
NEW
27
      clearTimeout(timer);
×
28
    }
29
  };
30
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc