Repository navigation
Fix the missing Redpanda version in the Bump widgets and the gulp bundle hang #453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ const fs = require('fs'); | |
| const path = require('path'); | ||
| const Handlebars = require('handlebars'); | ||
| const https = require('https'); | ||
| const yaml = require('js-yaml'); | ||
|
|
||
| const helpersDir = path.join(__dirname, 'src', 'helpers'); | ||
| if (fs.existsSync(helpersDir)) { | ||
|
|
@@ -19,28 +18,37 @@ if (fs.existsSync(helpersDir)) { | |
| }); | ||
| } | ||
|
|
||
| function fetchRemoteAntoraVersion() { | ||
| const url = 'https://raw.githubusercontent.com/redpanda-data/docs/main/antora.yml' | ||
| // The latest Self-Managed version, as the live docs site states it in every | ||
| // page's <meta name="latest-redpanda-version">. The site is public, so this | ||
| // needs no token (redpanda-data/docs, which holds antora.yml, is private). | ||
| const LATEST_VERSION_URL = 'https://docs.redpanda.com/home/' | ||
|
|
||
| function fetchLatestVersion () { | ||
| return new Promise((resolve, reject) => { | ||
| https.get(url, res => { | ||
| // agent: false so no kept-alive socket holds the process open afterwards. | ||
| const req = https.get(LATEST_VERSION_URL, { agent: false }, (res) => { | ||
| if (res.statusCode !== 200) { | ||
| return reject(new Error(`Failed to fetch antora.yml: ${res.statusCode}`)) | ||
| // Drain the response: an unread body keeps the socket, and the | ||
| // process, open, so the build would hang here. | ||
| res.resume() | ||
| return reject(new Error(`${LATEST_VERSION_URL} returned ${res.statusCode}`)) | ||
| } | ||
| let body = '' | ||
| res.on('data', chunk => (body += chunk)) | ||
| res.setEncoding('utf8') | ||
| // A connection dropped mid-body errors on res, not req. | ||
| res.on('error', reject) | ||
| res.on('data', (chunk) => (body += chunk)) | ||
| res.on('end', () => { | ||
| try { | ||
| const cfg = yaml.load(body) | ||
| if (cfg.version == null) { | ||
| throw new Error('version field missing') | ||
| } | ||
| const version = String(cfg.version).trim() | ||
| resolve(version) | ||
| } catch (err) { | ||
| reject(err) | ||
| const match = /<meta\s+name="latest-redpanda-version"\s+content="([^"]*)"/i.exec(body) | ||
| const version = match && match[1].trim() | ||
| if (!version || !/^\d+\.\d+$/.test(version)) { | ||
| return reject(new Error(`no latest-redpanda-version meta tag in ${LATEST_VERSION_URL}`)) | ||
| } | ||
| resolve(version) | ||
| }) | ||
| }).on('error', reject) | ||
| }) | ||
| req.on('error', reject) | ||
| req.setTimeout(10000, () => req.destroy(new Error('timed out after 10 s'))) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Set a deadline for the complete lookup.
🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not changing this: the socket timeout already covers a stalled connection, and a slow trickle from docs.redpanda.com is unlikely enough that an extra overall timer is not worth it here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @JakeSCahill Understood. You accept the residual risk of having no overall deadline for this lookup. I won’t press for an additional timer. You are interacting with an AI system. |
||
| }) | ||
| } | ||
|
|
||
|
|
@@ -122,13 +130,20 @@ async function ensureRootVersion(context) { | |
| return; | ||
| } | ||
|
|
||
| // Fallback: remote fetch | ||
| // Fallback: the live docs site | ||
| try { | ||
| const remoteVersion = await fetchRemoteAntoraVersion(); | ||
| const remoteVersion = await fetchLatestVersion(); | ||
| rootComponent.latest = rootComponent.latest || {}; | ||
| rootComponent.latest.version = remoteVersion; | ||
| } catch (err) { | ||
| console.warn(`⚠️ Could not fetch Antora version: ${err.message}`); | ||
| // Without a version the Bump widgets ship "Self-Managed v" as the search | ||
| // tag and an empty latest-redpanda-version meta tag, so a release build | ||
| // (CI) stops here. Locally it only warns, so the build works offline. | ||
| if (process.env.CI === 'true') { | ||
| console.error(`❌ Could not get the latest Redpanda version: ${err.message}. Set LATEST_ENTERPRISE to build without it.`); | ||
| process.exit(1); | ||
| } | ||
| console.warn(`⚠️ Could not get the latest Redpanda version: ${err.message}`); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.