From f3ab488fd894eea4175f6f77f147bd293db6a6c9 Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Tue, 14 Sep 2021 14:37:58 -0500 Subject: [PATCH 1/2] chore: fix TS 4.4 build in CI --- spec/schedulers/QueueScheduler-spec.ts | 2 +- spec/util/UnsubscriptionError-spec.ts | 11 +++++++---- src/internal/scheduler/AsyncAction.ts | 5 ++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/spec/schedulers/QueueScheduler-spec.ts b/spec/schedulers/QueueScheduler-spec.ts index 8c7f6f9219..2d0e9a0059 100644 --- a/spec/schedulers/QueueScheduler-spec.ts +++ b/spec/schedulers/QueueScheduler-spec.ts @@ -63,7 +63,7 @@ describe('Scheduler.queue', () => { const actions: Subscription[] = []; let action2Exec = false; let action3Exec = false; - let errorValue = undefined; + let errorValue: any = undefined; try { queue.schedule(() => { actions.push( diff --git a/spec/util/UnsubscriptionError-spec.ts b/spec/util/UnsubscriptionError-spec.ts index fc54c83332..5d9396a412 100644 --- a/spec/util/UnsubscriptionError-spec.ts +++ b/spec/util/UnsubscriptionError-spec.ts @@ -16,10 +16,13 @@ describe('UnsubscriptionError', () => { try { subscription.unsubscribe(); } catch (err) { - expect(err instanceof UnsubscriptionError).to.equal(true); - expect(err.errors).to.deep.equal([err1, err2]); - expect(err.name).to.equal('UnsubscriptionError'); - expect(err.stack).to.be.a('string'); + if (err instanceof UnsubscriptionError) { + expect(err.errors).to.deep.equal([err1, err2]); + expect(err.name).to.equal('UnsubscriptionError'); + expect(err.stack).to.be.a('string'); + } else { + throw new TypeError('Invalid error type'); + } } }); }); diff --git a/src/internal/scheduler/AsyncAction.ts b/src/internal/scheduler/AsyncAction.ts index 0731b7f166..d5fb03c460 100644 --- a/src/internal/scheduler/AsyncAction.ts +++ b/src/internal/scheduler/AsyncAction.ts @@ -116,7 +116,10 @@ export class AsyncAction extends Action { this.work(state); } catch (e) { errored = true; - errorValue = (!!e && e) || new Error(e); + // HACK: Since code elsewhere is relying on the "truthiness" of the + // return here, we can't have it return "" or 0 or false. + // TODO: Clean this up when we refactor schedulers mid-version-8 or so. + errorValue = e ? e : new Error('Falsy action error'); } if (errored) { this.unsubscribe(); From 17ebe88774373c853f9e0ef3c0a3d6921b1889dc Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Tue, 14 Sep 2021 14:44:11 -0500 Subject: [PATCH 2/2] chore: improve message --- src/internal/scheduler/AsyncAction.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/scheduler/AsyncAction.ts b/src/internal/scheduler/AsyncAction.ts index d5fb03c460..f7d600472e 100644 --- a/src/internal/scheduler/AsyncAction.ts +++ b/src/internal/scheduler/AsyncAction.ts @@ -119,7 +119,7 @@ export class AsyncAction extends Action { // HACK: Since code elsewhere is relying on the "truthiness" of the // return here, we can't have it return "" or 0 or false. // TODO: Clean this up when we refactor schedulers mid-version-8 or so. - errorValue = e ? e : new Error('Falsy action error'); + errorValue = e ? e : new Error('Scheduled action threw falsy error'); } if (errored) { this.unsubscribe();