Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

fix: prevent dedup crash #988

Merged
merged 3 commits into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
**Note:** This is a cumulative changelog that outlines all of the Apollo Link project child package changes that were bundled into a release on a specific day.

## 2019-03-14

### apollo-link-dedup 1.0.18

- Fixes an issue introduced in [#984](https://github.com/apollographql/apollo-link/pull/984)
where subscriber `next` and/or `error` calls might have already deleted the
key the new dedupe changes were intended to help with. <br/>
[@JoviDeCroock](https://github.com/JoviDeCroock) in [#988](https://github.com/apollographql/apollo-link/pull/988)


## 2019-03-13

### apollo-link-dedup 1.0.17
Expand Down
10 changes: 6 additions & 4 deletions packages/apollo-link-dedup/src/dedupLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ export class DedupLink extends ApolloLink {
}

return () => {
this.subscribers.get(key).delete(observer);
if (this.subscribers.get(key).size === 0) {
this.inFlightRequestObservables.delete(key);
if (subscription) subscription.unsubscribe();
if (this.subscribers.has(key)) {
this.subscribers.get(key).delete(observer);
if (this.subscribers.get(key).size === 0) {
this.inFlightRequestObservables.delete(key);
if (subscription) subscription.unsubscribe();
}
}
};
});
Expand Down