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

Undefined is not a function #425

Closed
1 task
jordyvandomselaar opened this issue Sep 16, 2019 · 12 comments
Closed
1 task

Undefined is not a function #425

jordyvandomselaar opened this issue Sep 16, 2019 · 12 comments

Comments

@jordyvandomselaar
Copy link

jordyvandomselaar commented Sep 16, 2019

I realize this is not enough information at all but I hope you can help me find the problem if possible.

Our Bugsnag is reporting the following error:

TypeError undefined is not a function 
    ../node_modules/immer/dist/immer.module.js:121 each
    ../node_modules/immer/dist/immer.module.js:503 Object.<anonymous>
    ../node_modules/immer/dist/immer.module.js:1113:15 Object.<anonymous>
    https://dwf.hockeyweerelt.nl/:1:1651 f
    api/comments.js:29:55 Object.push.615
    https://dwf.hockeyweerelt.nl/:1:1651 f
    https://dwf.hockeyweerelt.nl/static/js/main.7417baf1.chunk.js:1:84 Object.push.279
    https://dwf.hockeyweerelt.nl/:1:1651 f
    https://dwf.hockeyweerelt.nl/:1:1520 p
    https://dwf.hockeyweerelt.nl/:1:1383 Array.e [as push]

From what I can tell the problem comes from the following piece of code:

function each(value, cb) {
  if (Array.isArray(value)) {
    for (var i = 0; i < value.length; i++) {
      cb(i, value[i], value);
    }
  } else {
    ownKeys(value).forEach(function (key) {
      return cb(key, value[key], value);
    });
  }
}

Specifically ownKeys -- This is an assumption but I think ownKeys is somehow undefined. I came to this assumption because that's what's on line 121.

The affected browsers are:

  1. Edge 16.16299.0
  2. Edge 18.17763.0
  3. Edge 17.17134.0
  4. Chrome 60.0.3112
  5. Chrome 61.0.3163
  6. Chrome 72.0.3626
  7. Chrome 73.0.3683
  8. Chrome 74.0.3729
  9. Chrome 75.0.3770
  10. Chrome 76.0.3809

Reproduction

I honestly don't know, I've tried reproducing it but unfortunately

It works on my machine

I also can't reproduce it on BrowserStack.

Environment

  • Immer version: 1.7.2
  • [x ] Occurs with setUseProxies(true) -- Assuming this is the default
  • Occurs with setUseProxies(false) (ES5 only)
@mweststrate
Copy link
Collaborator

mweststrate commented Sep 16, 2019 via email

@jordyvandomselaar
Copy link
Author

Alright, thanks for having a look! I'll close this issue for now and re-open it if at some point I find more useful information.

@bensentropy
Copy link

bensentropy commented Dec 17, 2019

Just to add another (rather useless) datapoint, I have been getting this runtime issue as well in Rollbar with Immer 5.0.1.
The issue has appeared in a range of browsers Chrome 60 and 78 and is due to ownKeys not being defined. Also cant not reproduce.

@bbmreed
Copy link

bbmreed commented Mar 31, 2020

Also adding a (semi useless) datapoint in that we are seeing this often, with immer 6.0.1. We also use rollbar, seeing this a few hundred times a day, all on Windows 8/10, recent chrome (79, 80 at this time). Also no luck reproducing in browserstack. Seeing this come up across a few thousand different IPs, so it's not just a few odd users. I traced through our minified code to arrive at the some conclusion at the OP, in that ownKeys is somehow undefined.

Since I can't reproduce, or provide an isolated case, I know this is not super useful, but figured it was worth adding data points in case someone can build up a better picture.

mweststrate added a commit that referenced this issue Mar 31, 2020
@mweststrate
Copy link
Collaborator

I pushed a possible fix as 6.0.0-fix-425-2 . I think that should theoretically not happen, but feel free to roll it out at own risk and check if that removes the errors.

@mweststrate mweststrate reopened this Mar 31, 2020
@bbmreed
Copy link

bbmreed commented Apr 8, 2020

@mweststrate thanks for the patch fix. We pushed that out to production last week, and unfortunately, we're seeing the same rate of errors coming in. The only new information I have is that we've recently started seeing some errors from Edge 18 in addition to Chrome, but still all on Windows.

@njradford
Copy link

Also seeing this. Similarly all on Chrome/Windows users. Happens when redux-toolkit > immer calls ownKeys(value).forEach(...)

@mweststrate
Copy link
Collaborator

Would be great if people here share what webpack / babel / polyfill setups they are using. I highly suspect that there is a broken polyfill somewhere, that causes one of the built-ins used by ownKeys to be undefined, since the fallback getOwnPropertyNames should be supported by all browsers.

@mweststrate
Copy link
Collaborator

It would be great if someone could check if Immer 7 somehow magically fixes this :). Not that I did anything deliberately to address is, but some built-ins have been swapped with different functionality, and Immer can now handle polyfilled symbols better.

@ahce
Copy link

ahce commented Jun 13, 2020

Hi @mweststrate

I have this issue in react-native with immer v7 and hermes enabled (the issue only happens with hermes enabled).

Steps to reproduce:

  • Clone this repo
  • Run project (yarn android or yarn ios)
  • In the welcome screen touch the number

Immer v6 works with hermes.
You can change to immer v6 in these lines:

@elkinjosetm
Copy link

Hi @mweststrate

I have this issue in react-native with immer v7 and hermes enabled (the issue only happens with hermes enabled).

Steps to reproduce:

  • Clone this repo
  • Run project (yarn android or yarn ios)
  • In the welcome screen touch the number

Immer v6 works with hermes.
You can change to immer v6 in these lines:

Same here, I'm having the same issue when using v7 with Hermes enabled. Any idea on how to fix it using V7?

@mweststrate
Copy link
Collaborator

@ahce / @elkinjosetm could you please open a new issue, as this one is closed and about IE and Chrome, not hermes? Comments on closed issues are typically not seen by others.

If you could infer from the stack or a debugger break point which function is undefined that'd be great.

@immerjs immerjs locked and limited conversation to collaborators Jun 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants