nodejs/undici

fetch: wpt tests that are failing

Open

#1.666 geöffnet am 24. Sept. 2022

Auf GitHub ansehen
 (7 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (444 Forks)batch import
fetchgood first issuewpt

Repository-Metriken

Stars
 (5.319 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 2T 10h) (82 gemergte PRs in 30 T)

Beschreibung

We check if signal is aborted here: https://github.com/nodejs/undici/blob/9c3f34c97dfce7f7f6cffd04b7d4dab9921dc40d/lib/fetch/index.js#L126 and the promise gets rejected here: https://github.com/nodejs/undici/blob/9c3f34c97dfce7f7f6cffd04b7d4dab9921dc40d/lib/fetch/index.js#L304

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']);

Originally posted by @KhafraDev in https://github.com/nodejs/undici/issues/1664#issuecomment-1256836575

Contributor Guide