This is an automated email from the ASF dual-hosted git repository.

janhoy pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new fb67b7a43ea SOLR-18027 Proper fix for anotra bundle download timeout 
(#3952)
fb67b7a43ea is described below

commit fb67b7a43ea5850b8258bb5cf43f3afd797d59ec
Author: Jan Høydahl <[email protected]>
AuthorDate: Tue Dec 16 13:16:10 2025 +0100

    SOLR-18027 Proper fix for anotra bundle download timeout (#3952)
    
    (cherry picked from commit c7706feb09f76f0872b977f10146db99425e6511)
---
 solr/solr-ref-guide/build.gradle                | 12 ++---
 solr/solr-ref-guide/increase-request-timeout.js | 59 +++++++++++++++++++++++++
 solr/solr-ref-guide/increase-undici-timeout.js  | 45 -------------------
 3 files changed, 65 insertions(+), 51 deletions(-)

diff --git a/solr/solr-ref-guide/build.gradle b/solr/solr-ref-guide/build.gradle
index c61e74caee4..1b60fd741f5 100644
--- a/solr/solr-ref-guide/build.gradle
+++ b/solr/solr-ref-guide/build.gradle
@@ -416,15 +416,15 @@ task buildLocalAntoraSite(type: NpxTask) {
         "--fetch"
     ] + extraArgs
 
-    // Configure undici HTTP timeout via preload script to prevent timeout 
errors
+    // Configure HTTP request timeout via preload script to prevent timeout 
errors
     // when downloading UI bundle from slow networks (especially in CI)
-    def nodeOptions = "--require ${projectDir}/increase-undici-timeout.js"
+    def nodeOptions = "--require ${projectDir}/increase-request-timeout.js"
 
     environment = [
         "SITE_SEARCH_ENABLED": "true",
         "MATOMO_ENABLED": "false",
         "NODE_OPTIONS": nodeOptions,
-        "UNDICI_TIMEOUT_MS": "60000"  // 60 seconds timeout
+        "HTTP_REQUEST_TIMEOUT_MS": "60000"  // 60 seconds timeout
     ]
 
     inputs.files(fileTree(project.ext.siteStagingDir))
@@ -520,15 +520,15 @@ task buildOfficialSite(type: NpxTask) {
         officialPlaybook,
     ] + extraArgs
 
-    // Configure undici HTTP timeout via preload script to prevent timeout 
errors
+    // Configure HTTP request timeout via preload script to prevent timeout 
errors
     // when downloading UI bundle from slow networks (especially in CI)
-    def nodeOptions = "--require ${projectDir}/increase-undici-timeout.js"
+    def nodeOptions = "--require ${projectDir}/increase-request-timeout.js"
 
     environment = [
         "SITE_SEARCH_ENABLED": "true",
         "MATOMO_ENABLED": "true",
         "NODE_OPTIONS": nodeOptions,
-        "UNDICI_TIMEOUT_MS": "60000"  // 60 seconds timeout
+        "HTTP_REQUEST_TIMEOUT_MS": "60000"  // 60 seconds timeout
     ]
 
     inputs.files(officialPlaybook)
diff --git a/solr/solr-ref-guide/increase-request-timeout.js 
b/solr/solr-ref-guide/increase-request-timeout.js
new file mode 100644
index 00000000000..f29bc7bc887
--- /dev/null
+++ b/solr/solr-ref-guide/increase-request-timeout.js
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Preload script to increase HTTP request timeout for Antora UI bundle 
downloads.
+ *
+ * This script intercepts HTTP/HTTPS requests to set longer timeout values, 
preventing
+ * timeout errors when downloading the UI bundle from slow or high-latency 
networks,
+ * particularly in CI environments.
+ *
+ * Issue: Antora's UI bundle downloads (925KB from Apache's nightlies server) 
can timeout
+ * on slow networks. The simple-get library used by Antora doesn't set request 
timeouts
+ * by default, so we intercept http.request() and https.request() to add them.
+ *
+ * Usage: This script is preloaded via NODE_OPTIONS in the 
buildLocalAntoraSite task.
+ */
+
+// Configuration via environment variable
+const timeoutMs = parseInt(process.env.HTTP_REQUEST_TIMEOUT_MS || '60000', 10);
+
+// Configure HTTP request timeouts by intercepting request methods
+try {
+  const http = require('node:http');
+  const https = require('node:https');
+
+  // Intercept http.request to add timeout to each request
+  const originalHttpRequest = http.request;
+  http.request = function(...args) {
+    const req = originalHttpRequest.apply(this, args);
+    req.setTimeout(timeoutMs);
+    console.log(`[http-timeout] Modified http request to set timeout 
${timeoutMs}ms`);
+    return req;
+  };
+
+  // Intercept https.request to add timeout to each request
+  const originalHttpsRequest = https.request;
+  https.request = function(...args) {
+    const req = originalHttpsRequest.apply(this, args);
+    req.setTimeout(timeoutMs);
+    console.log(`[http-timeout] Modified https request to set timeout 
${timeoutMs}ms`);
+    return req;
+  };
+} catch (error) {
+  console.warn('[http-timeout] Could not configure HTTP request timeouts:', 
error.message);
+}
diff --git a/solr/solr-ref-guide/increase-undici-timeout.js 
b/solr/solr-ref-guide/increase-undici-timeout.js
deleted file mode 100644
index 3940fe951d7..00000000000
--- a/solr/solr-ref-guide/increase-undici-timeout.js
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Preload script to increase undici HTTP timeout for Antora UI bundle 
downloads.
- *
- * This script sets the global HTTP agent with longer timeout values to prevent
- * timeout errors when downloading the UI bundle from slow or high-latency 
networks,
- * particularly in CI environments.
- *
- * Issue: Node.js 20+ includes undici with default timeouts that may be too 
short
- * for downloading the Antora UI bundle (925KB) from Apache's nightlies server.
- *
- * Usage: This script is preloaded via NODE_OPTIONS in the 
buildLocalAntoraSite task.
- */
-
-// Configuration via environment variable
-const timeoutMs = parseInt(process.env.UNDICI_TIMEOUT_MS || '60000', 10);
-
-// Configure HTTP agent timeouts
-try {
-  const http = require('node:http');
-  const https = require('node:https');
-
-  http.globalAgent.timeout = timeoutMs;
-  https.globalAgent.timeout = timeoutMs;
-
-  console.log(`[undici-timeout] Configured HTTP agent timeouts: 
${timeoutMs}ms`);
-} catch (error) {
-  console.warn('[undici-timeout] Could not configure HTTP agent timeouts:', 
error.message);
-}

Reply via email to