TypeError: [object Object] is not iterable!↵ at push../node_modules/@babel/runtime-corejs2/node_modules/core-js/library/modules/_for-of.js.module.exports
- Dominant language
- TypeScript
- Stars
- 44k
- Forks
- 6k
- Avg merge
- 5d 15h
- Merged PRs (30d)
- 23
Description
## Bug Report
- [ ] I would like to work on a fix!
**Current Behavior**
A clear and concise description of the behavior.
I'm getting the following error after upgrading to next v9:
```
"TypeError: [object Object] is not iterable!
at push../node_modules/@babel/runtime-corejs2/node_modules/core-js/library/modules/_for-of.js.module.exports (http://localhost:3000/_next/static/runtime/main.js?ts=1582833143367:1602:42)
at http://localhost:3000/_next/static/runtime/main.js?ts=1582833143367:1326:34
at new Map (http://localhost:3000/_next/static/development/pages/searchPage.js?ts=1582833143367:24950:34)
at regionsReducer (http://localhost:3000/_next/static/development/pages/_app.js?ts=1582833143367:227410:30)
at combination (http://localhost:3000/_next/static/development/pages/searchPage.js?ts=1582833143367:172965:29)
at p (:1:36402)
at v (:1:36684)
at :1:40069
at Object.dispatch (http://localhost:3000/_next/static/development/pages/searchPage.js?ts=1582833143367:172719:22)
at e (:1:40553)
at http://localhost:3000/_next/static/development/pages/_app.js?ts=1582833143367:182911:16
at dispatch (http://localhost:3000/_next/static/development/pages/searchPage.js?ts=1582833143367:173144:28)
at http://localhost:3000/_next/static/development/pages/searchPage.js?ts=1582833143367:212336:9"
```
**Input Code**
- REPL or Repo link if applicable:
We have this code.
```js
case GET_REGIONS_BY_ID: {
const fetchedRegions = new Map(state.fetchedRegions)
```
**Expected behavior/code**
A clear and concise description of what you expected to happen (or code).
**Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)**
- Filename: `babel.config.js`
```js
{
"presets": ["next/babel"],
"plugins": [
[
"@babel/plugin-transform-runtime",
{
"absoluteRuntime": false,
"corejs": false,
"helpers": true,
"regenerator": true,
"useESModules": false,
"version": "7.0.0-beta.0"
}
],
["babel-plugin-root-import"],
["styled-components", { "ssr": true, "pure": true }],
[
"import",
{
"libraryName": "@material-ui/core",
"libraryDirectory": "",
"camel2DashComponentName": false
},
"import/core"
],
[
"import",
{
"libraryName": "@material-ui/icons",
"libraryDirectory": "",
"camel2DashComponentName": false
},
"import/icons"
]
],
"env": {
"test": {
"presets": [["next/babel", { "preset-env": { "modules": "commonjs" } }]]
}
}
}
```
**Environment**
```
npx: installed 1 in 1.124s
System:
OS: macOS 10.15.3
Binaries:
Node: 12.13.1 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.12.1 - /usr/local/bin/npm
npmPackages:
@babel/core: ^7.8.6 => 7.8.6
@babel/plugin-transform-runtime: ^7.8.3 => 7.8.3
babel-eslint: ^10.1.0 => 10.1.0
babel-jest: ^24.1.0 => 24.9.0
babel-loader: ^8.0.5 => 8.0.6
babel-plugin-import: ^1.12.2 => 1.13.0
babel-plugin-module-resolver: ^3.2.0 => 3.2.0
babel-plugin-root-import: ^5.1.0 => 5.1.0
babel-plugin-styled-components: ^1.10.7 => 1.10.7
babel-runtime: ^6.26.0 => 6.26.0
eslint: ^6.8.0 => 6.8.0
eslint-import-resolver-babel-plugin-root-import: ^1.1.1 => 1.1.1
jest: ^24.1.0 => 24.9.0
```
**Possible Solution**
I'm not sure if we need to upgrade some dependency or we need a polyfill. It's weird that after upgrading from next js 8 to 9 we get this issue.
**Additional context/Screenshots**
Add any other context about the problem here. If applicable, add screenshots to help explain.
Contributor guide
Research direction
Start with the provided GET_REGIONS_BY_ID snippet and babel.config.js, then trace the _for-of.js stack entry and the Map construction after upgrading from Next.js 8 to 9. Reproduce the TypeError with the listed Babel, Node, and Next.js setup; done means identifying whether the regression is in Babel configuration, a dependency, or iterable handling and validating the resulting fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, next.js
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100