mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-03 05:10:16 +03:00
# Description of Changes Changes - Use 127.0.0.1 instead of localhost for the local backend. The bundled backend starts on a random port and binds the IPv4 wildcard, but the frontend health-checked http://localhost:{port}. On macOS (and some Linux) localhost resolves to IPv6 ::1 first, so the connection is refused and every backend-dependent tool shows "backend offline" even though the backend started fine. Switched getBackendUrl() and the health-check URL to the 127.0.0.1 loopback literal (already in the Tauri HTTP capability allowlist, and what the OAuth loopback server already uses). Client-side tools were unaffected, which matches the reports. - Fail the desktop build when the bundled JRE is older than the app JAR. The app JAR is compiled for Java 25, but the bundle could ship an older runtime/jre (jlink:runtime short-circuits on an existing runtime, and nothing checked its version), producing UnsupportedClassVersionError at launch so the backend never starts. Added a jlink:verify task that reads the jlink release file and fails the build if the bundled JRE major is below REQUIRED_JAVA (25, kept in sync with build.gradle modernJavaVersion). It runs after the runtime is staged - including the short-circuit reuse path that lets a stale JRE slip through. Cross-platform Node script, no new dependencies. --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### Translations (if applicable) - [ ] I ran [`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have run `task check` to verify linters, typechecks, and tests pass - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#7-testing) for more details.
43 lines
1.6 KiB
JavaScript
43 lines
1.6 KiB
JavaScript
// Fail the desktop build if the bundled jlink runtime is older than the Java
|
|
// version the app JAR is compiled for. A too-old runtime ships happily today
|
|
// (the jlink task short-circuits on a stale runtime/jre, and nothing checks the
|
|
// version), then dies at launch with UnsupportedClassVersionError -> the
|
|
// backend never starts and every tool shows "backend offline".
|
|
//
|
|
// Reads JAVA_VERSION from the jlink `release` file (always present in a jlink
|
|
// output) so it needs no shell and behaves identically on Windows/macOS/Linux.
|
|
//
|
|
// Required major comes from REQUIRED_JAVA (wired from .taskfiles/desktop.yml,
|
|
// which mirrors build.gradle `modernJavaVersion`). Keep them in sync.
|
|
import { readFileSync } from "node:fs";
|
|
|
|
const required = Number(process.env.REQUIRED_JAVA ?? "25");
|
|
const releasePath = process.argv[2] ?? "runtime/jre/release";
|
|
|
|
let raw;
|
|
try {
|
|
raw = readFileSync(releasePath, "utf8");
|
|
} catch (err) {
|
|
console.error(
|
|
`FATAL: cannot read bundled JRE release file at "${releasePath}": ${err.message}. ` +
|
|
`Is the runtime built? Run 'task desktop:jlink'.`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
const match = raw.match(/JAVA_VERSION="?(\d+)/);
|
|
const major = match ? Number(match[1]) : 0;
|
|
|
|
console.log(
|
|
`Bundled JRE major: ${major || "unknown"} (required >= ${required})`,
|
|
);
|
|
|
|
if (!major || major < required) {
|
|
console.error(
|
|
`FATAL: bundled runtime/jre is Java ${major || "unknown"} but the app JAR requires ` +
|
|
`Java ${required}. Run 'task desktop:jlink:clean' and rebuild with JDK ${required} active ` +
|
|
`(check 'java -version' / JAVA_HOME).`,
|
|
);
|
|
process.exit(1);
|
|
}
|