Skip to content

Commit e23937d

Browse files
committed
refactor: Deprecate http2 as of Node 24
1 parent 41bc6f0 commit e23937d

2 files changed

Lines changed: 54 additions & 36 deletions

File tree

lib/server.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import portscanner from "portscanner";
33
import MiddlewareManager from "./middleware/MiddlewareManager.js";
44
import {createReaderCollection} from "@ui5/fs/resourceFactory";
55
import ReaderCollectionPrioritized from "@ui5/fs/ReaderCollectionPrioritized";
6+
import {getLogger} from "@ui5/logger";
67

8+
const log = getLogger("server");
79
/**
810
* @public
911
* @module @ui5/server
@@ -178,6 +180,12 @@ export async function serve(graph, {
178180
await middlewareManager.applyMiddleware(app);
179181

180182
if (h2) {
183+
const nodeVersion = parseInt(process.versions.node.split(".")[0], 10);
184+
if (nodeVersion >= 24) {
185+
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.");
186+
process.exit(1);
187+
}
188+
181189
app = await _addSsl({app, key, cert});
182190
}
183191

test/lib/server/h2.js

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,55 @@ import path from "node:path";
88
let request;
99
let server;
1010

11-
// Start server before running tests
12-
test.before(async (t) => {
13-
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
11+
const nodeVersion = parseInt(process.versions.node.split(".")[0], 10);
1412

15-
const graph = await graphFromPackageDependencies({
16-
cwd: "./test/fixtures/application.a"
17-
});
18-
const sslPath = path.join(process.cwd(), "./test/fixtures/ssl/");
19-
const {key, cert} = await getSslCertificate(
20-
path.join(sslPath, "server.key"),
21-
path.join(sslPath, "server.crt"),
22-
);
23-
server = await serve(graph, {
24-
port: 3366,
25-
h2: true,
26-
key,
27-
cert
13+
if (nodeVersion < 24) {
14+
// Start server before running tests
15+
test.before(async (t) => {
16+
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
17+
18+
const graph = await graphFromPackageDependencies({
19+
cwd: "./test/fixtures/application.a"
20+
});
21+
const sslPath = path.join(process.cwd(), "./test/fixtures/ssl/");
22+
const {key, cert} = await getSslCertificate(
23+
path.join(sslPath, "server.key"),
24+
path.join(sslPath, "server.crt"),
25+
);
26+
server = await serve(graph, {
27+
port: 3366,
28+
h2: true,
29+
key,
30+
cert
31+
});
32+
request = supertest("https://localhost:3366");
2833
});
29-
request = supertest("https://localhost:3366");
30-
});
3134

32-
test.after(() => {
33-
return new Promise((resolve, reject) => {
34-
server.close((error) => {
35-
if (error) {
36-
reject(error);
37-
} else {
38-
resolve();
39-
}
35+
test.after(() => {
36+
return new Promise((resolve, reject) => {
37+
server.close((error) => {
38+
if (error) {
39+
reject(error);
40+
} else {
41+
resolve();
42+
}
43+
});
4044
});
4145
});
42-
});
4346

44-
test("Get resource from application.a (/index.html)", async (t) => {
45-
const res = await request.get("/index.html");
46-
if (res.error) {
47-
t.fail(res.error.text);
48-
}
49-
t.is(res.statusCode, 200, "Correct HTTP status code");
50-
t.regex(res.headers["content-type"], /html/, "Correct content type");
51-
t.regex(res.text, /<title>Application A<\/title>/, "Correct response");
52-
});
47+
test("Get resource from application.a (/index.html)", async (t) => {
48+
const res = await request.get("/index.html");
49+
if (res.error) {
50+
t.fail(res.error.text);
51+
}
52+
t.is(res.statusCode, 200, "Correct HTTP status code");
53+
t.regex(res.headers["content-type"], /html/, "Correct content type");
54+
t.regex(res.text, /<title>Application A<\/title>/, "Correct response");
55+
});
56+
} else {
57+
test("HTTP Parser is missing", async (t) => {
58+
await t.throwsAsync(async () => {
59+
await import("spdy");
60+
});
61+
});
62+
}

0 commit comments

Comments
 (0)