From e23937d9b5101a116760d2a28d8bb041c9567b0a Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Fri, 30 May 2025 11:07:49 +0300 Subject: [PATCH 1/3] refactor: Deprecate http2 as of Node 24 --- lib/server.js | 8 +++++ test/lib/server/h2.js | 82 ++++++++++++++++++++++++------------------- 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/lib/server.js b/lib/server.js index 7c857148..922871cb 100644 --- a/lib/server.js +++ b/lib/server.js @@ -3,7 +3,9 @@ import portscanner from "portscanner"; import MiddlewareManager from "./middleware/MiddlewareManager.js"; import {createReaderCollection} from "@ui5/fs/resourceFactory"; import ReaderCollectionPrioritized from "@ui5/fs/ReaderCollectionPrioritized"; +import {getLogger} from "@ui5/logger"; +const log = getLogger("server"); /** * @public * @module @ui5/server @@ -178,6 +180,12 @@ export async function serve(graph, { await middlewareManager.applyMiddleware(app); if (h2) { + const nodeVersion = parseInt(process.versions.node.split(".")[0], 10); + if (nodeVersion >= 24) { + log.error("ERROR: This version of UI5 Tooling does not support HTTP/2 with Node v24 and later. Please check https://github.com/SAP/ui5-tooling/issues/327 for updates."); + process.exit(1); + } + app = await _addSsl({app, key, cert}); } diff --git a/test/lib/server/h2.js b/test/lib/server/h2.js index f8f004eb..6ccfc674 100644 --- a/test/lib/server/h2.js +++ b/test/lib/server/h2.js @@ -8,45 +8,55 @@ import path from "node:path"; let request; let server; -// Start server before running tests -test.before(async (t) => { - process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0"; +const nodeVersion = parseInt(process.versions.node.split(".")[0], 10); - const graph = await graphFromPackageDependencies({ - cwd: "./test/fixtures/application.a" - }); - const sslPath = path.join(process.cwd(), "./test/fixtures/ssl/"); - const {key, cert} = await getSslCertificate( - path.join(sslPath, "server.key"), - path.join(sslPath, "server.crt"), - ); - server = await serve(graph, { - port: 3366, - h2: true, - key, - cert +if (nodeVersion < 24) { + // Start server before running tests + test.before(async (t) => { + process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0"; + + const graph = await graphFromPackageDependencies({ + cwd: "./test/fixtures/application.a" + }); + const sslPath = path.join(process.cwd(), "./test/fixtures/ssl/"); + const {key, cert} = await getSslCertificate( + path.join(sslPath, "server.key"), + path.join(sslPath, "server.crt"), + ); + server = await serve(graph, { + port: 3366, + h2: true, + key, + cert + }); + request = supertest("https://localhost:3366"); }); - request = supertest("https://localhost:3366"); -}); -test.after(() => { - return new Promise((resolve, reject) => { - server.close((error) => { - if (error) { - reject(error); - } else { - resolve(); - } + test.after(() => { + return new Promise((resolve, reject) => { + server.close((error) => { + if (error) { + reject(error); + } else { + resolve(); + } + }); }); }); -}); -test("Get resource from application.a (/index.html)", async (t) => { - const res = await request.get("/index.html"); - if (res.error) { - t.fail(res.error.text); - } - t.is(res.statusCode, 200, "Correct HTTP status code"); - t.regex(res.headers["content-type"], /html/, "Correct content type"); - t.regex(res.text, /Application A<\/title>/, "Correct response"); -}); + test("Get resource from application.a (/index.html)", async (t) => { + const res = await request.get("/index.html"); + if (res.error) { + t.fail(res.error.text); + } + t.is(res.statusCode, 200, "Correct HTTP status code"); + t.regex(res.headers["content-type"], /html/, "Correct content type"); + t.regex(res.text, /<title>Application A<\/title>/, "Correct response"); + }); +} else { + test("HTTP Parser is missing", async (t) => { + await t.throwsAsync(async () => { + await import("spdy"); + }); + }); +} From 7a2a56788b178c93da0d396ca616bef45cf37190 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov <yavor.ivanov@sap.com> Date: Fri, 30 May 2025 11:11:04 +0300 Subject: [PATCH 2/3] docs: Add info to tests --- test/lib/server/h2.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/lib/server/h2.js b/test/lib/server/h2.js index 6ccfc674..42920393 100644 --- a/test/lib/server/h2.js +++ b/test/lib/server/h2.js @@ -10,6 +10,8 @@ let server; const nodeVersion = parseInt(process.versions.node.split(".")[0], 10); +// Withe Node.js 24 and later, the HTTP parser is missing, which breaks the HTTP/2 support in the spdy package. +// Tests need to be NodeJs version agnostic. if (nodeVersion < 24) { // Start server before running tests test.before(async (t) => { From 170a50f78ab19d3fb2f757f047d5315022c74e57 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov <yavor.ivanov@sap.com> Date: Fri, 30 May 2025 14:10:44 +0300 Subject: [PATCH 3/3] docs: Refactor log message --- lib/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server.js b/lib/server.js index 922871cb..eb865b04 100644 --- a/lib/server.js +++ b/lib/server.js @@ -182,7 +182,7 @@ export async function serve(graph, { if (h2) { const nodeVersion = parseInt(process.versions.node.split(".")[0], 10); if (nodeVersion >= 24) { - log.error("ERROR: This version of UI5 Tooling does not support HTTP/2 with Node v24 and later. Please check https://github.com/SAP/ui5-tooling/issues/327 for updates."); + log.error("ERROR: With Node v24, usage of HTTP/2 is no longer supported. Please check https://github.com/SAP/ui5-tooling/issues/327 for updates."); process.exit(1); }