Skip to content

Commit bde71ae

Browse files
committed
Fix sync XHR in Node.js v12
The `spawnSync()` buffer set in nodejs/node#23027 is too small for our use case. This sets the `maxBuffer` option to `Infinity` again as in previous versions of Node.js.
1 parent 7dd8f18 commit bde71ae

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

lib/jsdom/living/xmlhttprequest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ module.exports = function createXMLHttpRequest(window) {
611611
const res = spawnSync(
612612
process.execPath,
613613
[syncWorkerFile],
614-
{ input: flagStr }
614+
{ input: flagStr, maxBuffer: Infinity }
615615
);
616616
if (res.status !== 0) {
617617
throw new Error(res.stderr.toString());

test/web-platform-tests/run-wpts.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ const validReasons = new Set([
1313
"timeout",
1414
"flaky",
1515
"mutates-globals",
16+
"fails-node12",
1617
"needs-node10",
17-
"needs-node11"
18+
"needs-node11",
19+
"needs-node12"
1820
]);
1921

2022
const hasNode10 = Number(process.versions.node.split(".")[0]) >= 10;
2123
const hasNode11 = Number(process.versions.node.split(".")[0]) >= 11;
24+
const hasNode12 = Number(process.versions.node.split(".")[0]) >= 12;
2225

2326
const manifestFilename = path.resolve(__dirname, "wpt-manifest.json");
2427
const manifest = readManifest(manifestFilename);
@@ -54,8 +57,10 @@ describe("web-platform-tests", () => {
5457
const reason = matchingPattern && toRunDoc[matchingPattern][0];
5558
const shouldSkip = ["fail-slow", "timeout", "flaky", "mutates-globals"].includes(reason);
5659
const expectFail = (reason === "fail") ||
60+
(reason === "fails-node12" && hasNode12) ||
5761
(reason === "needs-node10" && !hasNode10) ||
58-
(reason === "needs-node11" && !hasNode11);
62+
(reason === "needs-node11" && !hasNode11) ||
63+
(reason === "needs-node12" && !hasNode12);
5964

6065
if (matchingPattern && shouldSkip) {
6166
specify.skip(`[${reason}] ${testFile}`);

test/web-platform-tests/to-run.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ basic.htm: [fail, Unknown]
2828
client-hint-request-headers-2.tentative.htm: [fail, Client Hints not implemented]
2929
client-hint-request-headers.htm: [fail-slow, Client Hints not implemented]
3030
cors-safelisted-request-header.any.html: [fail, Depends on fetch]
31-
credentials-flag.htm: [fail, Unknown]
31+
credentials-flag.htm: [needs-node12, Unknown]
3232
image-tainting-in-cross-origin-iframe.sub.html: [timeout, Unknown]
3333
origin.htm: [timeout, https://github.com/tmpvar/jsdom/issues/1833]
3434
preflight-cache.htm: [timeout, Cache should probably be implemented for simple requests before]
@@ -126,7 +126,7 @@ DIR: dom/nodes
126126
Comment-constructor.html: [fail, Unknown]
127127
DOMImplementation-createDocument.html: [fail, Unknown]
128128
Document-URL.html: [fail, Unknown]
129-
Document-characterSet-normalization.html: [fail, Some encodings are not supported - see the whatwg-encoding module]
129+
Document-characterSet-normalization.html: [timeout, Some encodings are not supported - see the whatwg-encoding module]
130130
Document-constructor-svg.svg: [fail, Unknown]
131131
Document-constructor-xml.xml: [fail, Unknown]
132132
Document-constructor.html: [fail, new Document().origin should inherit from current Document]
@@ -976,6 +976,7 @@ open-url-worker-origin.htm: [fail, Needs Worker implementation]
976976
open-url-worker-simple.htm: [timeout, Needs Worker implementation]
977977
overridemimetype-blob.html: [fail, Unknown]
978978
overridemimetype-edge-cases.window.html: [fail, Unknown]
979+
response-method.htm: [fails-node12, The behavior changed with Node's new HTTP parser, https://github.com/nodejs/node/issues/27049]
979980
responseType-document-in-worker.html: [fail, Needs Worker implementation]
980981
responseXML-unavailable-in-worker.html: [fail, Needs Worker implementation]
981982
responsedocument-decoding.htm: [fail, Unknown]

0 commit comments

Comments
 (0)