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

Cannot read property 'delete' of undefined #986

Closed
Fi1osof opened this issue Mar 14, 2019 · 24 comments · Fixed by #988
Closed

Cannot read property 'delete' of undefined #986

Fi1osof opened this issue Mar 14, 2019 · 24 comments · Fixed by #988
Assignees
Labels
blocking Prevents production or dev due to perf, bug, build error, etc.. bug

Comments

@Fi1osof
Copy link

Fi1osof commented Mar 14, 2019

After upgrade to apollo-link-dedup@1.0.17 got errors.

Uncaught TypeError: Cannot read property 'delete' of undefined
    at bundle.esm.js:67
    at cleanupSubscription (Observable.js:108)
    at notifySubscription (Observable.js:169)
    at onNotify (Observable.js:196)
    at SubscriptionObserver.complete (Observable.js:258)
    at bundle.esm.js:46
    at Set.forEach (<anonymous>)
    at Object.next (bundle.esm.js:45)
    at notifySubscription (Observable.js:152)
    at onNotify (Observable.js:196)
    at SubscriptionObserver.next (Observable.js:248)
    at Object.next (bundle.esm.js:32)
    at notifySubscription (Observable.js:152)
    at onNotify (Observable.js:196)
    at SubscriptionObserver.next (Observable.js:248)
    at index.js:171
@heyellieday
Copy link

I'm seeing this as well.

@devmeyster
Copy link

Yup seeing this too

@siddharth1903
Copy link

Same here...

@dinidu01
Copy link

dinidu01 commented Mar 14, 2019

As a workaround
package.json

"resolutions": {
    "apollo-link-dedup": "1.0.15"
  }
rm -rf node_modules
npx npm-force-resolutions
npm install

Check older version of apollo-link-dedup was installed
npm ls apollo-link-dedup

@mbrochh
Copy link

mbrochh commented Mar 14, 2019

@dinidu01 this is the first time I see that "resolutions" key in use. Would you mind explaining why this works? Couldn't I just pin the version of the package to "1.0.15" and get the same effect?

@JoviDeCroock
Copy link
Contributor

That means that your subscribers are undefined, anything specific you did to achieve this?

@mbrochh
Copy link

mbrochh commented Mar 14, 2019

@JoviDeCroock for me it happened magically over night without me changing any code. I suspect there is a bug in the zen-observable release that was released 5 hours ago.

@soulwu
Copy link

soulwu commented Mar 14, 2019

Same here, I debug it and found the missing key is an @client query

@JoviDeCroock
Copy link
Contributor

JoviDeCroock commented Mar 14, 2019

https://github.com/apollographql/apollo-link/blob/master/packages/apollo-link-dedup/src/dedupLink.ts#L65

This is a mistake I think, so we get a subscriber and call .delete on it. When the key has no result we shouldn't call anything on it.

@JoviDeCroock JoviDeCroock self-assigned this Mar 14, 2019
@JoviDeCroock JoviDeCroock added bug blocking Prevents production or dev due to perf, bug, build error, etc.. labels Mar 14, 2019
@julisman
Copy link

same here

TypeError: Cannot read property 'delete' of undefined
    at /xxx/node_modules/apollo-link-dedup/src/dedupLink.ts:66:36

@mantasindrasius
Copy link

Same here. Breaking our builds.

@nikita2423
Copy link

Same here :(

@hoangbkit
Copy link

same here, take me couple hours to figure it out from cicd flow :(

@JoviDeCroock
Copy link
Contributor

Let's not keep reacting same, it will make it harder for people to find the solution provided by @dinidu01. I'll have a PR ready to fix this tonight, let's resort to an emoji or something on OP's post if you are experiencing the same issue.

Sorry for the inconvenience, we'll work actively to fix this asap.

@Garik-
Copy link

Garik- commented Mar 14, 2019

/usr/src/app/node_modules/zen-observable/lib/Observable.js:63
      throw e;
      ^

TypeError: Cannot read property 'delete' of undefined
    at /usr/src/app/node_modules/apollo-link-dedup/lib/dedupLink.js:48:47
    at cleanupSubscription (/usr/src/app/node_modules/zen-observable/lib/Observable.js:90:7)
    at notifySubscription (/usr/src/app/node_modules/zen-observable/lib/Observable.js:145:41)
    at onNotify (/usr/src/app/node_modules/zen-observable/lib/Observable.js:165:3)
    at SubscriptionObserver.complete (/usr/src/app/node_modules/zen-observable/lib/Observable.js:229:7)
    at /usr/src/app/node_modules/apollo-link-dedup/lib/dedupLink.js:34:81
    at Set.forEach (<anonymous>)
    at Object.next (/usr/src/app/node_modules/apollo-link-dedup/lib/dedupLink.js:34:45)
    at notifySubscription (/usr/src/app/node_modules/zen-observable/lib/Observable.js:130:18)
    at onNotify (/usr/src/app/node_modules/zen-observable/lib/Observable.js:165:3)

@Fi1osof
Copy link
Author

Fi1osof commented Mar 14, 2019

@dinidu01 this is the first time I see that "resolutions" key in use. Would you mind explaining why this works? Couldn't I just pin the version of the package to "1.0.15" and get the same effect?

@mbrochh No, you couldn't. In this case y'll have more that one package with different versions. Try yarn add apollo-link-dedup@1.0.15 and then yarn why apollo-link-dedup after. Result:

[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "apollo-link-dedup@1.0.15"
info Has been hoisted to "apollo-link-dedup"
info This module exists because it's specified in "dependencies".
info Disk size without dependencies: "560KB"
info Disk size with unique dependencies: "1.67MB"
info Disk size with transitive dependencies: "3.48MB"
info Number of shared dependencies: 7
=> Found "apollo-client#apollo-link-dedup@1.0.16"
info This module exists because "apollo-client" depends on it.
info Disk size without dependencies: "540KB"
info Disk size with unique dependencies: "1.74MB"
info Disk size with transitive dependencies: "3.46MB"
info Number of shared dependencies: 7

With "resolutions" you got one package (on install after remove node_modules).

@hwillson
Copy link
Member

A fix for this is coming momentarily - sorry for the headache all!

@hwillson
Copy link
Member

hwillson commented Mar 14, 2019

apollo-link-dedup@1.0.18 should now fix this (thanks @JoviDeCroock!).

Just a heads up about apollo-link-dedup - this functionality is being merged into Apollo Client itself. This package will stay as is, but if you're using Apollo Client you're automatically using this package behind the scenes. When Apollo Client 2.6.0 is released, this will no longer be the case (since AC 2.6 will provide its own modified link deduplication functionality).

@mateuszwozniak
Copy link

Awesome, thanks for such quick fix guys!

@liamdanielduffy
Copy link

@hwillson

Unfortunately, after upgrading my dependencies, I'm still seeing this error, although with a slightly different stack trace. It seems to appear after every query.

My dependencies are:

    "apollo-cache-inmemory": "^1.5.1",
    "apollo-client": "^2.5.1",
    "apollo-link": "^1.2.10",
    "apollo-link-dedup": "^1.0.18",
    "apollo-link-error": "^1.1.9",
    "apollo-link-http": "^1.5.13",

The stack trace is:

bundle.esm.js:47 Uncaught TypeError: Cannot read property 'delete' of undefined
    at bundle.esm.js:47
    at cleanupSubscription (Observable.js:90)
    at notifySubscription (Observable.js:145)
    at onNotify (Observable.js:165)
    at SubscriptionObserver.complete (Observable.js:229)
    at bundle.esm.js:33
    at Set.forEach (<anonymous>)
    at Object.next (bundle.esm.js:33)
    at notifySubscription (Observable.js:130)
    at onNotify (Observable.js:165)
    at SubscriptionObserver.next (Observable.js:219)
    at bundle.esm.js:76

@JoviDeCroock
Copy link
Contributor

Try adding: "resolutions": {
"apollo-link-dedup": "1.0.18"
}

@liamdanielduffy
Copy link

liamdanielduffy commented Mar 25, 2019

Thanks @JoviDeCroock! That did the trick.

For anyone who runs into this in the future before 2.6, a summary of the fix:

  1. Install apollo-link-dedup@1.0.18
  2. Add the following to your package.json:
"resolutions": {
  "apollo-link-dedup": "1.0.18"
}

This will resolve the apollo-link-dedup dependency within Apollo Client (currently at 1.0.17), to 1.0.18 with the fix.

@JoviDeCroock
Copy link
Contributor

One of your dependencies is pulling apollo-link-dedup to the wrong dependency that's the danger of using ^ instead of just fixing your version.

@liamdanielduffy
Copy link

It seems like it was apollo client itself. Running npm ls apollo-link-dedup before adding the resolutions to my package.json gave me:

├─┬ apollo-client@2.5.1
│ └── apollo-link-dedup@1.0.17

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocking Prevents production or dev due to perf, bug, build error, etc.. bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.