Skip to content

Commit 06fe11f

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 e928ec8 commit 06fe11f

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ const validReasons = new Set([
1414
"flaky",
1515
"mutates-globals",
1616
"needs-node10",
17-
"needs-node11"
17+
"needs-node11",
18+
"needs-node12"
1819
]);
1920

2021
const hasNode10 = Number(process.versions.node.split(".")[0]) >= 10;
2122
const hasNode11 = Number(process.versions.node.split(".")[0]) >= 11;
23+
const hasNode12 = Number(process.versions.node.split(".")[0]) >= 12;
2224

2325
const manifestFilename = path.resolve(__dirname, "wpt-manifest.json");
2426
const manifest = readManifest(manifestFilename);
@@ -55,7 +57,8 @@ describe("web-platform-tests", () => {
5557
const shouldSkip = ["fail-slow", "timeout", "flaky", "mutates-globals"].includes(reason);
5658
const expectFail = (reason === "fail") ||
5759
(reason === "needs-node10" && !hasNode10) ||
58-
(reason === "needs-node11" && !hasNode11);
60+
(reason === "needs-node11" && !hasNode11) ||
61+
(reason === "needs-node12" && !hasNode12);
5962

6063
if (matchingPattern && shouldSkip) {
6164
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]
@@ -128,7 +128,7 @@ DIR: dom/nodes
128128
Comment-constructor.html: [fail, Unknown]
129129
DOMImplementation-createDocument.html: [fail, Unknown]
130130
Document-URL.html: [fail, Unknown]
131-
Document-characterSet-normalization.html: [fail, Some encodings are not supported - see the whatwg-encoding module]
131+
Document-characterSet-normalization.html: [timeout, Some encodings are not supported - see the whatwg-encoding module]
132132
Document-constructor-svg.svg: [fail, Unknown]
133133
Document-constructor-xml.xml: [fail, Unknown]
134134
Document-constructor.html: [fail, new Document().origin should inherit from current Document]
@@ -980,6 +980,7 @@ open-url-worker-origin.htm: [fail, Needs Worker implementation]
980980
open-url-worker-simple.htm: [timeout, Needs Worker implementation]
981981
overridemimetype-blob.html: [fail, Unknown]
982982
overridemimetype-edge-cases.window.html: [fail, Unknown]
983+
response-method.htm: [flaky, Usually fails with a Parse Error in Node.js v12, but occasionally passes as it did in previous versions]
983984
responseType-document-in-worker.html: [fail, Needs Worker implementation]
984985
responseXML-unavailable-in-worker.html: [fail, Needs Worker implementation]
985986
responsedocument-decoding.htm: [fail, Unknown]

0 commit comments

Comments
 (0)