8000 Abort signal is ignored when iterable doesn't yield anything · Issue #96 · alanshaw/abortable-iterator · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Abort signal is ignored when iterable doesn't yield anything #96
Open
@gnarea

Description

@gnarea

The first test times out and the second passes:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0