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

Error parsing undici module in Next.js 14 project #2207

Closed
sleipner01 opened this issue Apr 5, 2024 · 6 comments
Closed

Error parsing undici module in Next.js 14 project #2207

sleipner01 opened this issue Apr 5, 2024 · 6 comments
Assignees

Comments

@sleipner01
Copy link

πŸ› Bug Report

In a Next.js 14 project, my team and I encountered this problem Tuesday 2nd of April.
A member tried running the project after reinstalling node_modules and got the following error:

 β¨― ./node_modules/undici/lib/web/fetch/util.js
Module parse failed: Unexpected token (884:57)
|       // 5. If object is not a default iterator object for interface,
|       //    then throw a TypeError.
>       if (typeof this !== 'object' || this === null || !(#target in this)) {
|         throw new TypeError(
|           `'next' called on an object that does not implement interface ${name} Iterator.`

Import trace for requested module:
./node_modules/undici/lib/web/fetch/util.js
./node_modules/undici/lib/web/fetch/index.js
./node_modules/undici/index.js
./node_modules/@elastic/transport/lib/connection/UndiciConnection.js
./node_modules/@elastic/transport/lib/connection/index.js
./node_modules/@elastic/transport/index.js
./node_modules/@elastic/elasticsearch/index.js
./src/search/client.ts
./src/search/search.ts

April 2nd both undici and @elastic/transport had version updates.

I managed to "mitigate" the problem by downgrading @elastic/transport to version 8.4.1. This forced undici to version 5.28.4 (looking at package-lock.json)

To Reproduce

Using any elastic Client initialisation with Next.js 14.

Any standard Next.js package.json containing the following:
"@elastic/elasticsearch": "^8.12.2",

Having the caret character is essential to reproduce the error.

Run: npm install
Run: npm run dev

Expected behavior

Build/run successfully

Environment

  • node version: 20+
  • @elastic/elasticsearch version: 8.13.0
  • os: macOS Sonoma 14.4
  • Next.js: 14.1.0
  • @elastic/transport: ^8.4.0
  • undici: ^6.7.0
@JoshMock JoshMock added the bug label Apr 8, 2024
@JoshMock JoshMock self-assigned this Apr 8, 2024
@JoshMock
Copy link
Member

JoshMock commented Apr 8, 2024

Semi-related to elastic/elastic-transport-js#91

I'll put out patch versions of 8.x versions of this package this week to help mitigate.

@JoshMock
Copy link
Member

JoshMock commented Apr 9, 2024

@sleipner01 Please try upgrading @elastic/elasticsearch to 8.13.1 to see if it resolves this issue.

@sleipner01
Copy link
Author

@JoshMock The upgrade resolved the problem in our project. Thanks:)

@dylanhu7
Copy link

@JoshMock After upgrading to 8.14 from 8.13, it seems this issue has resurfaced. I am also using Next 14, and [email protected]

@dylanhu7
Copy link

@JoshMock After upgrading to 8.14 from 8.13, it seems this issue has resurfaced. I am also using Next 14, and [email protected]

Never mind, it seems updating to [email protected] fixed it.

@sanny085
Copy link

sanny085 commented Sep 4, 2024

@JoshMock After upgrading to 8.14 from 8.13, it seems this issue has resurfaced. I am also using Next 14, and [email protected]

Never mind, it seems updating to [email protected] fixed it.

After updating from "next": "14.0.4" to "next": "^14.2.5". issue resolved, Thanks @dylanhu7 πŸ₯³

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants