Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f3518f3

Browse filesBrowse files
deokjinkimjuanarbol
authored andcommitted
test: use process.hrtime.bigint instead of process.hrtime
`process.hrtime` is legacy. So replace `process.hrtime` with `process.hrtime.bigint` in test. Refs: https://github.com/nodejs/node/blob/main/doc/api/process.md#processhrtimetime Signed-off-by: Deokjin Kim <deokjin81.kim@gmail.com> PR-URL: #45877 Refs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent b239f06 commit f3518f3
Copy full SHA for f3518f3

File tree

Expand file treeCollapse file tree

1 file changed

+10
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-8
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-http2-session-timeout.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-session-timeout.js
+10-8Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ if (!common.hasCrypto)
55
common.skip('missing crypto');
66
const assert = require('assert');
77
const http2 = require('http2');
8+
const hrtime = process.hrtime.bigint;
9+
const NS_PER_MS = 1_000_000n;
810

911
let requests = 0;
1012
const mustNotCall = () => {
@@ -14,7 +16,7 @@ const mustNotCall = () => {
1416
const server = http2.createServer();
1517
// Disable server timeout until first request. We will set the timeout based on
1618
// how long the first request takes.
17-
server.timeout = 0;
19+
server.timeout = 0n;
1820

1921
server.on('request', (req, res) => res.end());
2022
server.on('timeout', mustNotCall);
@@ -24,7 +26,7 @@ server.listen(0, common.mustCall(() => {
2426

2527
const url = `http://localhost:${port}`;
2628
const client = http2.connect(url);
27-
let startTime = process.hrtime();
29+
let startTime = hrtime();
2830
makeReq();
2931

3032
function makeReq() {
@@ -40,17 +42,17 @@ server.listen(0, common.mustCall(() => {
4042
requests += 1;
4143

4244
request.on('end', () => {
43-
const diff = process.hrtime(startTime);
44-
const milliseconds = (diff[0] * 1e3 + diff[1] / 1e6);
45-
if (server.timeout === 0) {
45+
const diff = hrtime() - startTime;
46+
const milliseconds = diff / NS_PER_MS;
47+
if (server.timeout === 0n) {
4648
// Set the timeout now. First connection will take significantly longer
4749
// than subsequent connections, so using the duration of the first
4850
// connection as the timeout should be robust. Double it anyway for good
4951
// measure.
50-
server.timeout = milliseconds * 2;
51-
startTime = process.hrtime();
52+
server.timeout = milliseconds * 2n;
53+
startTime = hrtime();
5254
makeReq();
53-
} else if (milliseconds < server.timeout * 2) {
55+
} else if (milliseconds < server.timeout * 2n) {
5456
makeReq();
5557
} else {
5658
server.removeListener('timeout', mustNotCall);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.