Conversation
This comment was marked as outdated.
This comment was marked as outdated.
|
This test is failing and I'm not really sure how to fix it 😕 import { fetch, setGlobalOrigin } from 'undici'
import assert from 'assert'
setGlobalOrigin('http://localhost:3000')
const controller = new AbortController();
const signal = controller.signal;
controller.abort();
const log = [];
await Promise.all([
fetch('../resources/data.json', { signal }).then(
() => assert_unreached("Fetch must not resolve"),
() => log.push('fetch-reject')
),
Promise.resolve().then(() => log.push('next-microtask'))
]);
assert.deepStrictEqual(log, ['fetch-reject', 'next-microtask']); |
Codecov ReportBase: 94.89% // Head: 94.90% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1664 +/- ##
==========================================
+ Coverage 94.89% 94.90% +0.01%
==========================================
Files 53 53
Lines 4803 4813 +10
==========================================
+ Hits 4558 4568 +10
Misses 245 245
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
|
The edit: the issue is the order in which the promise is resolved/rejected. I don't know how to solve this without breaking the spec. function createDeferredPromise () {
let res
let rej
const promise = new Promise((resolve, reject) => {
res = resolve
rej = reject
})
return { promise, resolve: res, reject: rej }
}
async function fetch () {
const promise = createDeferredPromise()
queueMicrotask(() => promise.reject(new Error('AbortError')))
promise.resolve()
return promise.promise
}
await fetch() // resolves |
* feat(WPTRunner): parse `META` tags * feat: add more routes * feat: add /resources/data.json route * fix(fetch): throw AbortError DOMException on consume if aborted * fix(fetch): throw AbortError on `.formData()` after abort * feat: add expected failures & end log * fix: import DOMException for node 16 * feat: run each test in its own worker & simplify worker
* feat(WPTRunner): parse `META` tags * feat: add more routes * feat: add /resources/data.json route * fix(fetch): throw AbortError DOMException on consume if aborted * fix(fetch): throw AbortError on `.formData()` after abort * feat: add expected failures & end log * fix: import DOMException for node 16 * feat: run each test in its own worker & simplify worker
METAtags and injecting individual scripts into each test. Example ofMETAtags: https://github.com/web-platform-tests/wpt/blob/master/fetch/api/abort/general.any.js#L1-L5