Skip to content

Commit ab99638

Browse files
authored
fix(wpt): broken test (nodejs#1683)
* fix(wpt): broken test * fix: failing node-fetch tests * fix: more failing tests
1 parent 0983859 commit ab99638

File tree

6 files changed

+10
-14
lines changed

6 files changed

+10
-14
lines changed

lib/fetch/request.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -949,11 +949,7 @@ webidl.converters.RequestInit = webidl.dictionaryConverter([
949949
{
950950
key: 'duplex',
951951
converter: webidl.converters.DOMString,
952-
allowedValues: ['half'],
953-
// TODO(@KhafraDev): this behavior is incorrect, but
954-
// without it, a WPT throws with an uncaught exception,
955-
// causing the entire WPT runner to crash.
956-
defaultValue: 'half'
952+
allowedValues: ['half']
957953
}
958954
])
959955

test/fetch/client-fetch.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ test('pre aborted with readable request body', (t) => {
111111
async cancel (reason) {
112112
t.equal(reason.name, 'AbortError')
113113
}
114-
})
114+
}),
115+
duplex: 'half'
115116
}).catch(err => {
116117
t.equal(err.name, 'AbortError')
117118
})
@@ -141,7 +142,8 @@ test('pre aborted with closed readable request body', (t) => {
141142
fetch(`http://localhost:${server.address().port}`, {
142143
signal: ac.signal,
143144
method: 'POST',
144-
body
145+
body,
146+
duplex: 'half'
145147
}).catch(err => {
146148
t.equal(err.name, 'AbortError')
147149
})

test/node-fetch/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,8 @@ describe('node-fetch', () => {
11351135
const url = `${base}inspect`
11361136
const options = {
11371137
method: 'POST',
1138-
body: stream.Readable.from('a=1')
1138+
body: stream.Readable.from('a=1'),
1139+
duplex: 'half'
11391140
}
11401141
return fetch(url, options).then(res => {
11411142
return res.json()

test/node-fetch/request.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ describe('Request', () => {
207207
follow: 3,
208208
compress: false,
209209
agent,
210-
signal
210+
signal,
211+
duplex: 'half'
211212
})
212213
const cl = request.clone()
213214
expect(cl.url).to.equal(url)

test/wpt/status/fetch.status.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
{
2-
"request-init-stream.any.js": {
3-
"fail": [
4-
"It is error to omit .duplex when the body is a ReadableStream."
5-
]
6-
},
72
"general.any.js": {
83
"fail": [
94
"Stream errors once aborted. Underlying connection closed.",

test/wpt/tests/fetch/api/abort/general.any.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ promise_test(async t => {
490490
const fetchPromise = fetch('../resources/empty.txt', {
491491
body, signal,
492492
method: 'POST',
493+
duplex: 'half',
493494
headers: {
494495
'Content-Type': 'text/plain'
495496
}

0 commit comments

Comments
 (0)