Skip to content

Commit 2851507

Browse files
authored
fix: ensure we honor first-byte-timeout and between-bytes-timeout for dynamically registered backends (#719)
1 parent 3b03a72 commit 2851507

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

integration-tests/js-compute/fixtures/app/src/dynamic-backend.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/// <reference path="../../../../../types/index.d.ts" />
12
import { Backend } from 'fastly:backend';
23
import { CacheOverride } from 'fastly:cache-override';
34
import { allowDynamicBackends } from "fastly:experimental";
@@ -6,6 +7,33 @@ import { isRunningLocally, routes } from "./routes.js";
67

78
/// The backend name is already in use.
89

10+
routes.set("/backend/timeout", async () => {
11+
if (isRunningLocally()) {
12+
return pass('ok')
13+
}
14+
allowDynamicBackends(true);
15+
let backend = new Backend(
16+
{
17+
name: 'httpme1',
18+
target: 'http-me.glitch.me',
19+
hostOverride: "http-me.glitch.me",
20+
useSSL: true,
21+
dontPool: true,
22+
betweenBytesTimeout: 1_000,
23+
connectTimeout: 1_000,
24+
firstByteTimeout: 1_000
25+
}
26+
);
27+
console.time(`fetch('https://http-me.glitch.me/test?wait=5000'`)
28+
let error = await assertRejects(() => fetch('https://http-me.glitch.me/test?wait=5000', {
29+
backend,
30+
cacheOverride: new CacheOverride("pass"),
31+
}));
32+
console.timeEnd(`fetch('https://http-me.glitch.me/test?wait=5000'`)
33+
if (error) { return error }
34+
return pass('ok')
35+
});
36+
937

1038
// implicit dynamic backend
1139
{

integration-tests/js-compute/fixtures/app/tests.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,6 +2131,17 @@
21312131
"body": "ok"
21322132
}
21332133
},
2134+
"GET /backend/timeout": {
2135+
"environments": ["compute"],
2136+
"downstream_request": {
2137+
"method": "GET",
2138+
"pathname": "/backend/timeout"
2139+
},
2140+
"downstream_response": {
2141+
"status": 200,
2142+
"body": "ok"
2143+
}
2144+
},
21342145
"GET /implicit-dynamic-backend/dynamic-backends-disabled": {
21352146
"environments": ["viceroy"],
21362147
"downstream_request": {

runtime/js-compute-runtime/host_interface/component/fastly_world_adapter.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,17 +496,23 @@ bool fastly_compute_at_edge_http_req_register_dynamic_backend(
496496
fastly_compute_at_edge_types_error_t *err) {
497497
uint32_t backend_config_mask = 0;
498498

499+
if (config->use_ssl.is_some && config->use_ssl.val) {
500+
backend_config_mask |= BACKEND_CONFIG_USE_SSL;
501+
}
502+
if (config->dont_pool.is_some && config->dont_pool.val) {
503+
backend_config_mask |= BACKEND_CONFIG_DONT_POOL;
504+
}
499505
if (config->host_override.is_some) {
500506
backend_config_mask |= BACKEND_CONFIG_HOST_OVERRIDE;
501507
}
502508
if (config->connect_timeout.is_some) {
503509
backend_config_mask |= BACKEND_CONFIG_CONNECT_TIMEOUT;
504510
}
505-
if (config->use_ssl.is_some && config->use_ssl.val) {
506-
backend_config_mask |= BACKEND_CONFIG_USE_SSL;
511+
if (config->first_byte_timeout.is_some) {
512+
backend_config_mask |= BACKEND_CONFIG_FIRST_BYTE_TIMEOUT;
507513
}
508-
if (config->dont_pool.is_some && config->dont_pool.val) {
509-
backend_config_mask |= BACKEND_CONFIG_DONT_POOL;
514+
if (config->between_bytes_timeout.is_some) {
515+
backend_config_mask |= BACKEND_CONFIG_BETWEEN_BYTES_TIMEOUT;
510516
}
511517
if (config->ssl_min_version.is_some) {
512518
backend_config_mask |= BACKEND_CONFIG_SSL_MIN_VERSION;

0 commit comments

Comments
 (0)