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

cofacts / rumors-api / 13481192372

23 Feb 2025 08:16AM UTC coverage: 82.956% (-0.1%) from 83.059%
13481192372

Pull #362

github

MrOrz
test(timeoutHeader): skip timeout logic in test
Pull Request #362: Proxy read timeout mitigation

775 of 983 branches covered (78.84%)

Branch coverage included in aggregate %.

2 of 6 new or added lines in 2 files covered. (33.33%)

1498 of 1757 relevant lines covered (85.26%)

18.89 hits per line

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

33.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 timeout - Timeout in milliseconds before sending the header. Default to lower than Cloudflare's Proxy Read Timeout.
7
 * @returns Koa middleware function
8
 */
9
export default function timeoutHeader(timeout = 90000) {
1✔
10
  return async (ctx: Context, next: Next): Promise<void> => {
1✔
11
    // Create a timer to send headers
NEW
12
    const timer = setTimeout(() => /* istanbul ignore next */ {
×
13
      if (!ctx.headerSent) {
14
        console.log(
15
          '[timeoutHeader] Sending preliminary header after',
16
          timeout,
17
          'ms'
18
        );
19
        ctx.set('Content-Encoding', 'identity');
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