Skip to content

Commit 506333e

Browse files
committed
More fixes
1 parent d446b08 commit 506333e

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

packages/common/src/utils/async.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ export function asyncNotifier(): AsyncNotifier {
4747
},
4848
waitForNotification(signal: AbortSignal) {
4949
return new Promise((resolve) => {
50-
if (hasPendingNotification) {
50+
if (signal.aborted) {
51+
resolve();
52+
} else if (hasPendingNotification) {
5153
resolve();
5254
hasPendingNotification = false;
5355
} else {
@@ -65,11 +67,7 @@ export function asyncNotifier(): AsyncNotifier {
6567
}
6668

6769
waitingConsumers.push(complete);
68-
if (signal.aborted) {
69-
onAbort();
70-
} else {
71-
signal.addEventListener('abort', onAbort);
72-
}
70+
signal.addEventListener('abort', onAbort);
7371
}
7472
});
7573
}

packages/common/tests/utils/async.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, expect, test } from 'vitest';
22
import { asyncNotifier } from '../../src/utils/async';
33

4-
describe('notifyIterator', () => {
4+
describe('asyncNotifier', () => {
55
const neverAbort = new AbortController().signal;
66

77
test('waits for event', async () => {

packages/node/tests/sync.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ function defineSyncTests(bson: boolean) {
549549
await database.execute('INSERT INTO lists (id, name) values (uuid(), ?)', ['local write']);
550550

551551
syncService.installRequestInterceptor(async (request) => {
552-
if (request.url.indexOf('/sync/stream') != -1) {
552+
if (request.url.includes('/sync/stream')) {
553553
throw new Error('Pretend that the service is unavailable');
554554
}
555555
});

0 commit comments

Comments
 (0)