Skip to content

Commit abed2e6

Browse files
committed
remove unnecessary stop on error
for our purposes, we can just halt the executor
1 parent e7ae944 commit abed2e6

File tree

2 files changed

+5
-26
lines changed

2 files changed

+5
-26
lines changed

src/execution/Queue.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@ export class Queue<T> {
2525
try {
2626
result = executor(this._push.bind(this), this.stop.bind(this));
2727
} catch {
28-
// Ignore actual error
29-
this.stop();
28+
// ignore errors
3029
}
3130
if (isPromise(result)) {
3231
result.catch(() => {
33-
// Ignore actual error
34-
this.stop();
32+
// ignore errors
3533
});
3634
}
3735
}

src/execution/__tests__/Queue-test.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ describe('Queue', () => {
4949
});
5050

5151
it('should allow the executor to indicate completion', async () => {
52-
const queue = new Queue<number>(async (_push, stop) => {
53-
await resolveOnNextTick();
52+
const queue = new Queue<number>((push, stop) => {
5453
stop();
54+
push(1); // should be ignored
5555
});
5656

5757
const sub = queue.subscribe((batch) => batch);
5858
expect(await sub.next()).to.deep.equal({ done: true, value: undefined });
5959
});
6060

61-
it('should allow a consumer to abort a pending call to nextBatch', async () => {
61+
it('should allow a consumer to abort a pending call to next', async () => {
6262
const queue = new Queue<number>(async () => {
6363
const { promise } = promiseWithResolvers();
6464
// wait forever
@@ -87,25 +87,6 @@ describe('Queue', () => {
8787
expect(await sub.next()).to.deep.equal({ done: false, value: [1, 2, 3] });
8888
});
8989

90-
it('should stop on sync error in the executor', async () => {
91-
const queue = new Queue<number>(() => {
92-
throw new Error('Oops');
93-
});
94-
95-
const sub = queue.subscribe((batch) => Array.from(batch));
96-
expect(await sub.next()).to.deep.equal({ done: true, value: undefined });
97-
});
98-
99-
it('should stop on async errors in the executor', async () => {
100-
const queue = new Queue<number>(async () => {
101-
await resolveOnNextTick();
102-
throw new Error('Oops');
103-
});
104-
105-
const sub = queue.subscribe((batch) => Array.from(batch));
106-
expect(await sub.next()).to.deep.equal({ done: true, value: undefined });
107-
});
108-
10990
it('should skip payloads when mapped to undefined, skipping first async payload', async () => {
11091
const queue = new Queue<number>(async (push) => {
11192
await resolveOnNextTick();

0 commit comments

Comments
 (0)