alanshaw / alanshaw/abortable-iterator
Abort signal is ignored when iterable doesn't yield anything
- Vorherrschende Sprache
- TypeScript
- Sterne
- 16
- Forks
- 7
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
The first test times out and the second passes:
```typescript
import { PassThrough } from 'stream';
import { source as makeSourceAbortable } from 'abortable-iterator';
test('Empty source', async () => {
const source = new PassThrough();
const abortController = new AbortController();
const abortableSource = makeSourceAbortable(source, abortController.signal, {
returnOnAbort: true,
});
setImmediate(() => abortController.abort());
for await (const chunk of abortableSource) {
throw new Error(`Shouldn't have got ${chunk}`);
}
});
test('Non-empty source', async () => {
const source = new PassThrough();
const abortController = new AbortController();
const abortableSource = makeSourceAbortable(source, abortController.signal, {
returnOnAbort: true,
});
setImmediate(() => {
source.write('foo');
abortController.abort();
});
for await (const chunk of abortableSource) {
expect(chunk).toBe('foo');
}
});
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.