-
Notifications
You must be signed in to change notification settings - Fork 572
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
Failing JSON parsing in Node 22 #3328
Comments
@KhafraDev Seems valid. |
@stefan-garofalo can you try to isolate what combination of response body + headers is causing this? In order to fix we need a server that reproduces the problem, otherwise it's impossible to find out. Nothing really stands up by looking at the diffs. |
I managed to specifically install the latest node 22 version (22.3.0) locally and now I am actually reproducing the error outside of github workers too. This is the response: Response {
status: 200,
statusText: '',
headers: Headers {
'access-control-allow-headers': 'Authorization, X-WP-Nonce, Content-Disposition, Content-MD5, Content-Type',
'access-control-expose-headers': 'X-WP-Total, X-WP-TotalPages, Link',
allow: 'GET',
'content-type': 'application/json; charset=UTF-8',
date: 'Fri, 14 Jun 2024 09:30:02 GMT',
link: '<MY_CMS_URL>; rel="https://api.w.org/"',
server: 'Apache/2.4.59 (Debian)',
vary: 'Origin',
'x-content-type-options': 'nosniff',
'x-powered-by': 'PHP/8.2.19',
'x-robots-tag': 'noindex',
'x-wp-total': '1',
'x-wp-totalpages': '1',
'transfer-encoding': 'chunked'
},
body: ReadableStream { locked: false, state: 'readable', supportsBYOB: true },
bodyUsed: false,
ok: true,
redirected: false,
type: 'default',
url: 'MY_CMS_URL'
} And here follows the body [
{
"id": 13,
"date": "2024-05-29T11:49:34",
"date_gmt": "2024-05-29T09:49:34",
"guid": {
"rendered": "MY_CMS_URL"
},
"modified": "2024-06-13T17:35:54",
"modified_gmt": "2024-06-13T15:35:54",
"slug": "homepage",
"status": "publish",
"type": "page",
"link": "MY_CMS_URL",
"title": {
"rendered": "Homepage"
},
"content": {
"rendered": "",
"protected": false
},
"excerpt": {
"rendered": "",
"protected": false
},
"author": 1,
"featured_media": 0,
"parent": 0,
"menu_order": 4,
"comment_status": "closed",
"ping_status": "closed",
"template": "",
"meta": {
"footnotes": ""
},
"acf": {
"hero": {
"titolo": "LOREM IPSUM DOLOR SIT AMET, CONSETETUR SADIPSCING ELITR SED DIAM",
"paragrafo": "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
"cta": {
"etichetta": "lorem",
"link": "/"
}
},
"pagine": {
"lista": [49, 67]
},
"storie": {
"titolo": "Lorem",
"lista": [
{
"titolo": "Lorem ipsum dolor sit amet consetetur",
"cover": {
"ID": 44,
"id": 44,
"status": "inherit",
"uploaded_to": 13,
"date": "2024-05-30 15:24:42",
"modified": "2024-05-30 15:24:48",
"menu_order": 0,
"mime_type": "image/png",
"type": "image",
"subtype": "png",
"width": 1830,
"height": 1866,
"sizes": {
"thumbnail-width": 150,
"thumbnail-height": 150,
"medium-width": 294,
"medium-height": 300,
"medium_large-width": 768,
"medium_large-height": 783,
"large-width": 1004,
"large-height": 1024,
"1536x1536-width": 1506,
"1536x1536-height": 1536,
"2048x2048-width": 1830,
"2048x2048-height": 1866
}
},
"colore": "light"
},
{
"titolo": "Lorem ipsum dolor sit amet consetetur",
"cover": {
"ID": 44,
"id": 44,
"filesize": 89931,
"author": "1",
"uploaded_to": 13,
"date": "2024-05-30 15:24:42",
"modified": "2024-05-30 15:24:48",
"menu_order": 0,
"mime_type": "image/png",
"type": "image",
"subtype": "png",
"width": 1830,
"height": 1866,
"sizes": {
"thumbnail-width": 150,
"thumbnail-height": 150,
"medium-width": 294,
"medium-height": 300,
"medium_large-width": 768,
"medium_large-height": 783,
"large-width": 1004,
"large-height": 1024,
"1536x1536-width": 1506,
"1536x1536-height": 1536,
"2048x2048-width": 1830,
"2048x2048-height": 1866
}
},
"colore": "white"
},
{
"titolo": "Lorem ipsum dolor sit amet consetetur",
"cover": {
"ID": 44,
"id": 44,
"filesize": 89931,
"author": "1",
"status": "inherit",
"uploaded_to": 13,
"date": "2024-05-30 15:24:42",
"modified": "2024-05-30 15:24:48",
"menu_order": 0,
"mime_type": "image/png",
"type": "image",
"subtype": "png",
"width": 1830,
"height": 1866,
"sizes": {
"thumbnail-width": 150,
"thumbnail-height": 150,
"medium-width": 294,
"medium-height": 300,
"medium_large-width": 768,
"medium_large-height": 783,
"large-width": 1004,
"large-height": 1024,
"1536x1536-width": 1506,
"1536x1536-height": 1536,
"2048x2048-width": 1830,
"2048x2048-height": 1866
}
},
"colore": "secondary"
},
{
"titolo": "Lorem ipsum dolor sit amet consetetur",
"cover": {
"ID": 44,
"id": 44,
"filesize": 89931,
"author": "1",
"status": "inherit",
"uploaded_to": 13,
"date": "2024-05-30 15:24:42",
"modified": "2024-05-30 15:24:48",
"menu_order": 0,
"mime_type": "image/png",
"type": "image",
"subtype": "png",
"width": 1830,
"height": 1866,
"sizes": {
"thumbnail-width": 150,
"thumbnail-height": 150,
"medium-width": 294,
"medium-height": 300,
"medium_large": "MY_CMS_URL/wp-content/uploads/2024/05/logobuzzi-768x783.png",
"medium_large-width": 768,
"medium_large-height": 783,
"large-width": 1004,
"large-height": 1024,
"1536x1536-width": 1506,
"1536x1536-height": 1536,
"2048x2048-width": 1830,
"2048x2048-height": 1866
}
},
"colore": "light"
}
]
},
"buca": {
"titolo": "LOREM IPSUM DOLOR SIT AMET",
"paragrafo": "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum."
},
"seo": {
"title": "Homepage",
"description": "Lorem ipsum dolor homepage",
"image": false
}
},
"_links": {
"self": [
{
"href": "MY_CMS_URL"
}
],
"collection": [
{
"href": "MY_CMS_URL"
}
],
"about": [
{
"href": "MY_CMS_URL"
}
],
"author": [
{
"embeddable": true,
"href": "MY_CMS_URL"
}
],
"replies": [
{
"embeddable": true,
"href": "MY_CMS_URL"
}
],
"version-history": [
{
"count": 9,
"href": "MY_CMS_URL"
}
],
"predecessor-version": [
{
"id": 204,
"href": "MY_CMS_URL"
}
],
"wp:attachment": [
{
"href": "MY_CMS_URL"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
}
]
awaiting |
@stefan-garofalo can you include a complete example on reproducing it outside of GitHub Actions? Ideally client+server. |
@mcollina I tried to reproduce it. When asked to provide headers and body as you requested I did |
But I also failed to reproduce the issue outside of my current nextjs project. I tried node only with |
Keep going at it, without the reproduction will be impossible to fix :(.
|
So I guess its not really about undici. Maybe some conflicts between fetch ad Nextjs patches? Should I reopen this issue in Nextjs repository? |
Possibly, we can investigate if we have a reproduction. |
I encountered similar issues: |
We need a minimal reproduction to be able to fix. |
afaik nextjs patches fetch which likely causes the issue. Without more information it looks like they're not decompressing the body. |
Bug Description
When making a fetch call the JSON parsing fails and spits out some broken chars. This only happens in Node 22.3.0, does not happen in node 22.1.0
Reproducible By
Fetching data from an API (in my case Wordpress) and parsing the body as json. Currently this happens in a Next.js project. When reaching my homepage I make a call to my cms
Expected Behavior
The JSON being parsed correctly. This behavior came up circa 3 days ago, I figure it has something to do with the latest Node 22.3.0 release
Logs & Screenshots
I added a trycatch to log the query if failing to see more clearly in the github logs, since I firstly bumped into the problem during a github action build
Environment
Github worker using the latest Node 22.3.0 Docker image, but it also happens locally using the latest Node 22.3.0
Additional context
My application code did not change in such a timeframe, nor its configs. I managed to work around the issue and correctly publish my repository's images by downgrading to Node 20.
Since the stack trace refers to files inside /undici I figured issuing in this repository would have fit better rather than Node itself
The text was updated successfully, but these errors were encountered: