Skip to content

Commit

Permalink
add fix
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Nov 10, 2023
1 parent b25f1ef commit 2abfbf5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/utilities/observables/Concast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,7 @@ export class Concast<T> extends Observable<T> {
} else if (isPromiseLike(value)) {
value.then(
(obs) => (this.sub = obs.subscribe(this.handlers)),
() => {
// add error handler here to silence unhandled promise rejection
// so the tests can run at all, but do not fix yet
// to show the memory leak
}
this.handlers.error
);
} else {
this.sub = value.subscribe(this.handlers);
Expand Down
4 changes: 2 additions & 2 deletions src/utilities/observables/__tests__/Concast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ describe("Concast Observable (similar to Behavior Subject in RxJS)", () => {
await expect(observerRefs[0]).toBeGarbageCollected();
});

it.failing("rejecting a source-wrapping promise of a concast frees all observer references on `this.observers`", async () => {
it("rejecting a source-wrapping promise of a concast frees all observer references on `this.observers`", async () => {
const { promise, reject } = deferred<Observable<number>>();
const observers: Observer<any>[] = [{ next() {}, error() {} }];
const observerRefs = observers.map((observer) => new WeakRef(observer));
Expand Down Expand Up @@ -268,7 +268,7 @@ describe("Concast Observable (similar to Behavior Subject in RxJS)", () => {
await expect(observerRefs[0]).toBeGarbageCollected();
});

it.failing("after subscribing to an already-rejected concast, the reference is freed up again", async () => {
it("after subscribing to an already-rejected concast, the reference is freed up again", async () => {
const concast = new Concast<number>([Promise.reject("error")]);
await expect(concast.promise).rejects.toBe("error");
await Promise.resolve();
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.tests.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"lib": ["es2015", "esnext.asynciterable", "dom", "ES2021.WeakRef"],
},
"include": ["src/**/__tests__/**/*.ts", "src/**/__tests__/**/*.tsx"],
"exclude": []
}

0 comments on commit 2abfbf5

Please sign in to comment.