Skip to content

Commit e6c1972

Browse files
authored
Merge branch 'main' into codeowners
2 parents d2b0196 + 7f06c27 commit e6c1972

40 files changed

+486
-211
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -361,5 +361,6 @@ module.exports = {
361361
WritableStream: 'readable',
362362
WritableStreamDefaultWriter: 'readable',
363363
WritableStreamDefaultController: 'readable',
364+
WebSocket: 'readable',
364365
},
365366
};
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const assert = require('assert');
5+
6+
const bench = common.createBenchmark(main, {
7+
n: [1e6],
8+
code: [
9+
'built-in',
10+
'ERR_HTTP2_STREAM_SELF_DEPENDENCY',
11+
'ERR_INVALID_STATE',
12+
'ERR_INVALID_URL',
13+
],
14+
stackTraceLimit: [0, 10],
15+
}, {
16+
flags: ['--expose-internals'],
17+
});
18+
19+
function getErrorFactory(code) {
20+
const {
21+
ERR_HTTP2_STREAM_SELF_DEPENDENCY,
22+
ERR_INVALID_STATE,
23+
ERR_INVALID_URL,
24+
} = require('internal/errors').codes;
25+
26+
switch (code) {
27+
case 'built-in':
28+
return (n) => new Error();
29+
case 'ERR_HTTP2_STREAM_SELF_DEPENDENCY':
30+
return (n) => new ERR_HTTP2_STREAM_SELF_DEPENDENCY();
31+
case 'ERR_INVALID_STATE':
32+
return (n) => new ERR_INVALID_STATE(n + '');
33+
case 'ERR_INVALID_URL':
34+
return (n) => new ERR_INVALID_URL({ input: n + '' });
35+
default:
36+
throw new Error(`${code} not supported`);
37+
}
38+
}
39+
40+
function main({ n, code, stackTraceLimit }) {
41+
const getError = getErrorFactory(code);
42+
43+
Error.stackTraceLimit = stackTraceLimit;
44+
45+
// Warm up.
46+
const length = 1024;
47+
const array = [];
48+
for (let i = 0; i < length; ++i) {
49+
array.push(getError(i));
50+
}
51+
52+
bench.start();
53+
54+
for (let i = 0; i < n; ++i) {
55+
const index = i % length;
56+
array[index] = getError(index);
57+
}
58+
59+
bench.end(n);
60+
61+
// Verify the entries to prevent dead code elimination from making
62+
// the benchmark invalid.
63+
for (let i = 0; i < length; ++i) {
64+
assert.strictEqual(typeof array[i], 'object');
65+
}
66+
}

benchmark/error/node-error-stack.js

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const assert = require('assert');
5+
6+
const bench = common.createBenchmark(main, {
7+
n: [1e6],
8+
code: [
9+
'built-in',
10+
'ERR_HTTP2_STREAM_SELF_DEPENDENCY',
11+
'ERR_INVALID_STATE',
12+
],
13+
stackTraceLimit: [0, 10],
14+
}, {
15+
flags: ['--expose-internals'],
16+
});
17+
18+
function getErrorStackFactory(code) {
19+
const {
20+
ERR_INVALID_STATE,
21+
ERR_HTTP2_STREAM_SELF_DEPENDENCY,
22+
} = require('internal/errors').codes;
23+
24+
switch (code) {
25+
case 'built-in':
26+
return (n) => new Error().stack;
27+
case 'ERR_HTTP2_STREAM_SELF_DEPENDENCY':
28+
return (n) => new ERR_HTTP2_STREAM_SELF_DEPENDENCY().stack;
29+
case 'ERR_INVALID_STATE':
30+
return (n) => new ERR_INVALID_STATE(n + '').stack;
31+
default:
32+
throw new Error(`${code} not supported`);
33+
}
34+
}
35+
36+
function main({ n, code, stackTraceLimit }) {
37+
const getStack = getErrorStackFactory(code);
38+
39+
Error.stackTraceLimit = stackTraceLimit;
40+
41+
// Warm up.
42+
const length = 1024;
43+
const array = [];
44+
for (let i = 0; i < length; ++i) {
45+
array.push(getStack(i));
46+
}
47+
48+
bench.start();
49+
50+
for (let i = 0; i < n; ++i) {
51+
const index = i % length;
52+
array[index] = getStack(index);
53+
}
54+
55+
bench.end(n);
56+
57+
// Verify the entries to prevent dead code elimination from making
58+
// the benchmark invalid.
59+
for (let i = 0; i < length; ++i) {
60+
assert.strictEqual(typeof array[i], 'string');
61+
}
62+
}

benchmark/error/node-error.js

-21
This file was deleted.

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.18',
39+
'v8_embedder_string': '-node.19',
4040

4141
##### V8 defaults for Node.js #####
4242

deps/v8/src/snapshot/embedded/platform-embedded-file-writer-base.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ EmbeddedTargetOs ToEmbeddedTargetOs(const char* s) {
130130
}
131131

132132
std::string string(s);
133-
if (string == "aix") {
133+
// Python 3.9+ on IBM i returns os400 as sys.platform instead of aix
134+
if (string == "aix" || string == "os400") {
134135
return EmbeddedTargetOs::kAIX;
135136
} else if (string == "chromeos") {
136137
return EmbeddedTargetOs::kChromeOS;

doc/api/cli.md

+10
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,14 @@ added: v12.3.0
738738

739739
Enable experimental WebAssembly module support.
740740

741+
### `--experimental-websocket`
742+
743+
<!-- YAML
744+
added: REPLACEME
745+
-->
746+
747+
Enable experimental [`WebSocket`][] support.
748+
741749
### `--force-context-aware`
742750

743751
<!-- YAML
@@ -2248,6 +2256,7 @@ Node.js options that are allowed are:
22482256
* `--experimental-vm-modules`
22492257
* `--experimental-wasi-unstable-preview1`
22502258
* `--experimental-wasm-modules`
2259+
* `--experimental-websocket`
22512260
* `--force-context-aware`
22522261
* `--force-fips`
22532262
* `--force-node-api-uncaught-exceptions-policy`
@@ -2715,6 +2724,7 @@ done
27152724
[`NODE_OPTIONS`]: #node_optionsoptions
27162725
[`NO_COLOR`]: https://no-color.org
27172726
[`SlowBuffer`]: buffer.md#class-slowbuffer
2727+
[`WebSocket`]: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
27182728
[`YoungGenerationSizeFromSemiSpaceSize`]: https://chromium.googlesource.com/v8/v8.git/+/refs/tags/10.3.129/src/heap/heap.cc#328
27192729
[`dns.lookup()`]: dns.md#dnslookuphostname-options-callback
27202730
[`dns.setDefaultResultOrder()`]: dns.md#dnssetdefaultresultorderorder

doc/api/globals.md

+13
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,17 @@ The object that acts as the namespace for all W3C
10181018
[WebAssembly][webassembly-org] related functionality. See the
10191019
[Mozilla Developer Network][webassembly-mdn] for usage and compatibility.
10201020

1021+
## `WebSocket`
1022+
1023+
<!-- YAML
1024+
added: REPLACEME
1025+
-->
1026+
1027+
> Stability: 1 - Experimental.
1028+
1029+
A browser-compatible implementation of [`WebSocket`][]. Enable this API
1030+
with the [`--experimental-websocket`][] CLI flag.
1031+
10211032
## Class: `WritableStream`
10221033

10231034
<!-- YAML
@@ -1052,6 +1063,7 @@ A browser-compatible implementation of [`WritableStreamDefaultWriter`][].
10521063
[ECMAScript module]: esm.md
10531064
[Navigator API]: https://html.spec.whatwg.org/multipage/system-state.html#the-navigator-object
10541065
[Web Crypto API]: webcrypto.md
1066+
[`--experimental-websocket`]: cli.md#--experimental-websocket
10551067
[`--no-experimental-global-customevent`]: cli.md#--no-experimental-global-customevent
10561068
[`--no-experimental-global-webcrypto`]: cli.md#--no-experimental-global-webcrypto
10571069
[`AbortController`]: https://developer.mozilla.org/en-US/docs/Web/API/AbortController
@@ -1085,6 +1097,7 @@ A browser-compatible implementation of [`WritableStreamDefaultWriter`][].
10851097
[`TransformStream`]: webstreams.md#class-transformstream
10861098
[`URLSearchParams`]: url.md#class-urlsearchparams
10871099
[`URL`]: url.md#class-url
1100+
[`WebSocket`]: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
10881101
[`WritableStreamDefaultController`]: webstreams.md#class-writablestreamdefaultcontroller
10891102
[`WritableStreamDefaultWriter`]: webstreams.md#class-writablestreamdefaultwriter
10901103
[`WritableStream`]: webstreams.md#class-writablestream

doc/node.1

+3
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ Use this flag to enable ShadowRealm support.
178178
.It Fl -experimental-test-coverage
179179
Enable code coverage in the test runner.
180180
.
181+
.It Fl -experimental-websocket
182+
Enable experimental support for the WebSocket API.
183+
.
181184
.It Fl -no-experimental-fetch
182185
Disable experimental support for the Fetch API.
183186
.

doc/template.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</head>
1515
<body class="alt apidoc" id="api-section-__FILENAME__">
1616
<div id="content" class="clearfix">
17-
<div id="column2" class="interior">
17+
<div role="navigation" id="column2" class="interior">
1818
<div id="intro" class="interior">
1919
<a href="/" title="Go back to the home page">
2020
Node.js
@@ -70,7 +70,7 @@ <h1>Node.js __VERSION__ documentation</h1>
7070

7171
__TOC__
7272

73-
<div id="apicontent">
73+
<div role="main" id="apicontent">
7474
__CONTENT__
7575
<!-- API END -->
7676
</div>

lib/internal/blob.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ const {
2424
concat,
2525
getDataObject,
2626
} = internalBinding('blob');
27+
const {
28+
kMaxLength,
29+
} = internalBinding('buffer');
2730

2831
const {
2932
TextDecoder,
@@ -62,7 +65,6 @@ const {
6265
} = require('internal/errors');
6366

6467
const {
65-
isUint32,
6668
validateDictionary,
6769
} = require('internal/validators');
6870

@@ -160,8 +162,8 @@ class Blob {
160162
return src;
161163
});
162164

163-
if (!isUint32(length))
164-
throw new ERR_BUFFER_TOO_LARGE(0xFFFFFFFF);
165+
if (length > kMaxLength)
166+
throw new ERR_BUFFER_TOO_LARGE(kMaxLength);
165167

166168
this[kHandle] = _createBlob(sources_, length);
167169
this[kLength] = length;

lib/internal/crypto/hkdf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const validateParameters = hideStackFrames((hash, key, salt, info, length) => {
5757
validateInteger(length, 'length', 0, kMaxLength);
5858

5959
if (info.byteLength > 1024) {
60-
throw ERR_OUT_OF_RANGE(
60+
throw new ERR_OUT_OF_RANGE(
6161
'info',
6262
'must not contain more than 1024 bytes',
6363
info.byteLength);

0 commit comments

Comments
 (0)