Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on IE11 #4024

Closed
oliviertassinari opened this issue Oct 18, 2018 · 6 comments
Closed

Crash on IE11 #4024

oliviertassinari opened this issue Oct 18, 2018 · 6 comments
Assignees

Comments

@oliviertassinari
Copy link

oliviertassinari commented Oct 18, 2018

Intended outcome:

No error.

Actual outcome:

Unable to get property 'get' of undefined or null reference

capture d ecran 2018-10-18 a 12 14 12

How to reproduce the issue:

Go to IE 11 and run:

function getOrCreate(value) {
  var map = new Map();
  return map.get(value) || map.set(value, 'foo').get(value);
}

getOrCreate(undefined)

from:

getOrCreate(value: any): CacheKeyNode<KeyType> {
const map = this.children || (this.children = new Map);
return map.get(value) || map.set(value, new CacheKeyNode<KeyType>()).get(value);
}

Versions

apollo-cache-inmemory@^1.3.5:
  version "1.3.5"
  resolved "https://registry.yarnpkg.com/apollo-cache-inmemory/-/apollo-cache-inmemory-1.3.5.tgz#7628ee598271cfffa611e15a7ce67652a84b07b0"
  dependencies:
    apollo-cache "^1.1.17"
    apollo-utilities "^1.0.21"
    optimism "^0.6.6"
@oliviertassinari
Copy link
Author

oliviertassinari commented Oct 18, 2018

Even better:

new Map().set('foo', 'bar')

returns undefined on IE 11 when it returns itself on the latest implementations.

@oliviertassinari
Copy link
Author

The following implementation works:

    CacheKeyNode.prototype.getOrCreate = function (value) {
        var map = this.children || (this.children = new Map);
        var output = map.get(value)
        if (output) {
            return output
        }
        output = new CacheKeyNode()
        map.set(value, output)
        return output
    };

@oliviertassinari
Copy link
Author

oliviertassinari commented Oct 19, 2018

Same report here: vercel/next.js#5426.

@oliviertassinari
Copy link
Author

According to @barnslig, it's a regression, it used to work in v1.2.10.

benjamn added a commit to ooflorent/apollo-client that referenced this issue Oct 24, 2018
Implementing my own suggestion:
apollographql#4012 (review)

This change would be sufficient to fix apollographql#4024, though apollographql#4012 helps as well.
@benjamn benjamn self-assigned this Oct 26, 2018
@benjamn
Copy link
Member

benjamn commented Oct 26, 2018

This should be fixed with apollo-cache-inmemory@1.3.7 (just published).

@oliviertassinari
Copy link
Author

Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants