Skip to content

Commit c8f89d5

Browse files
Update Node.js Engine Inventory (#1494)
* Update Inventory for heroku/nodejs-engine ### Added - Node.js 25.0.0 (linux-amd64) - Node.js 22.21.0 (linux-amd64) * Add hatchet tests for Node 25 * Loosen bundled npm version check in test --------- Co-authored-by: heroku-linguist[bot] <136119646+heroku-linguist[bot]@users.noreply.github.com> Co-authored-by: Colin Casey <[email protected]>
1 parent 78fce51 commit c8f89d5

File tree

13 files changed

+181
-3
lines changed

13 files changed

+181
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [Unreleased]
44

5+
- Added Node.js 25.0.0 (linux-amd64)
6+
- Added Node.js 22.21.0 (linux-amd64)
57

68
## [v314] - 2025-10-09
79

inventory/node.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
[[artifacts]]
2+
version = "25.0.0"
3+
os = "linux"
4+
arch = "amd64"
5+
url = "https://nodejs.org/download/release/v25.0.0/node-v25.0.0-linux-x64.tar.gz"
6+
checksum = "sha256:28dd46a6733192647d7c8267343f5a3f1c616f773c448e2c0d2539ae70724b40"
7+
18
[[artifacts]]
29
version = "24.10.0"
310
os = "linux"
@@ -194,6 +201,13 @@ arch = "amd64"
194201
url = "https://nodejs.org/download/release/v23.0.0/node-v23.0.0-linux-x64.tar.gz"
195202
checksum = "sha256:702cbc710fcf1102cef1aced74443fee34eff8df4827de30ec970d377ce31d9e"
196203

204+
[[artifacts]]
205+
version = "22.21.0"
206+
os = "linux"
207+
arch = "amd64"
208+
url = "https://nodejs.org/download/release/v22.21.0/node-v22.21.0-linux-x64.tar.gz"
209+
checksum = "sha256:262b84b02f7e2bc017d4bdb81fec85ca0d6190a5cd0781d2d6e84317c08871f8"
210+
197211
[[artifacts]]
198212
version = "22.20.0"
199213
os = "linux"

spec/ci/node_25_metrics_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require_relative '../spec_helper'
2+
3+
describe "Node Metrics for v25.x" do
4+
context "test metrics for Node v25.x app" do
5+
let(:app) {
6+
Hatchet::Runner.new(
7+
"spec/fixtures/repos/node-25-metrics",
8+
config: {
9+
"HEROKU_METRICS_URL" => "http://localhost:3000",
10+
"METRICS_INTERVAL_OVERRIDE" => "10000"
11+
}
12+
)
13+
}
14+
15+
it "should deploy" do
16+
app.deploy do |app|
17+
data = successful_json_body(app)
18+
expect(data["gauges"]["node.eventloop.delay.ms.max"]).to be >= 2000
19+
expect(data["counters"]["node.gc.collections"]).to be >= 0
20+
expect(data["counters"]["node.gc.young.collections"]).to be >= 0
21+
expect(data["counters"]["node.gc.old.collections"]).to be >= 0
22+
end
23+
end
24+
end
25+
end

spec/ci/node_25_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require_relative '../spec_helper'
2+
3+
describe "Hello World for Node v25.x" do
4+
context "a single-process Node v25.x app" do
5+
let(:app) {
6+
Hatchet::Runner.new("spec/fixtures/repos/node-25")
7+
}
8+
9+
it "should deploy successfully" do
10+
app.deploy do |app|
11+
expect(successful_body(app).strip).to eq("Hello, world!")
12+
end
13+
end
14+
end
15+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: node index.js
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env node
2+
3+
const http = require('http');
4+
const EventEmitter = require('events');
5+
6+
const PORT = process.env.PORT || 5000;
7+
const Events = new EventEmitter();
8+
9+
// This will block the event loop for ~lengths of time
10+
function blockCpuFor(ms) {
11+
return new Promise((resolve, reject) => {
12+
setTimeout(() => {
13+
console.log(`blocking the event loop for ${ms}ms`);
14+
let now = new Date().getTime();
15+
let result = 0
16+
while(true) {
17+
result += Math.random() * Math.random();
18+
if (new Date().getTime() > now + ms)
19+
break;
20+
}
21+
resolve();
22+
}, 100);
23+
});
24+
}
25+
26+
function getNextMetricsEvent() {
27+
return new Promise((resolve, reject) => Events.once('metrics', resolve));
28+
}
29+
30+
const server = http.createServer((req, res) => {
31+
// wait for the next metrics event
32+
getNextMetricsEvent()
33+
.then(blockCpuFor(2000))
34+
.then(blockCpuFor(100))
35+
.then(blockCpuFor(100))
36+
.then(blockCpuFor(100))
37+
.then(blockCpuFor(100))
38+
.then(blockCpuFor(100))
39+
.then(blockCpuFor(100))
40+
.then(blockCpuFor(100))
41+
.then(blockCpuFor(100))
42+
.then(blockCpuFor(100))
43+
.then(blockCpuFor(100))
44+
// gather the next metrics data which should include these pauses
45+
.then(getNextMetricsEvent())
46+
.then(data => {
47+
res.setHeader('Content-Type', 'application/json');
48+
res.end(data);
49+
})
50+
.catch(() => {
51+
res.statusCode = 500;
52+
res.end("Something went wrong");
53+
});
54+
});
55+
56+
server.listen(PORT, () => console.log(`Listening on ${PORT}`));
57+
58+
// Create a second server that intercepts the HTTP requests
59+
// sent by the metrics plugin
60+
const metricsListener = http.createServer((req, res) => {
61+
if (req.method == 'POST') {
62+
let body = '';
63+
req.on('data', (data) => body += data);
64+
req.on('end', () => {
65+
res.statusCode = 200;
66+
res.end();
67+
Events.emit('metrics', body)
68+
});
69+
}
70+
});
71+
72+
metricsListener.listen(3000, () => console.log('Listening for metrics on 3000'));
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "node-metrics-test-app",
3+
"version": "1.0.0",
4+
"engines": {
5+
"node": "25.x"
6+
},
7+
"main": "index.js",
8+
"license": "MIT",
9+
"devDependencies": {},
10+
"dependencies": {}
11+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: node index.js
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "hello-world"
3+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env node
2+
3+
const http = require('http');
4+
5+
const PORT = process.env.PORT || 5000;
6+
7+
const server = http.createServer((_req, res) => {
8+
res.statusCode = 200;
9+
res.setHeader('Content-Type', 'text/plain');
10+
res.end("Hello, world!");
11+
})
12+
13+
server.listen(PORT, () => console.log(`Listening on ${PORT}`));

0 commit comments

Comments
 (0)