Title: Requests to google apis failing with `Premature close` on 22.23.0 tags · Issue #2544 · nodejs/docker-node · GitHub
Open Graph Title: Requests to google apis failing with `Premature close` on 22.23.0 tags · Issue #2544 · nodejs/docker-node
X Title: Requests to google apis failing with `Premature close` on 22.23.0 tags · Issue #2544 · nodejs/docker-node
Description: We ran into an issue with our deployments using the 22-alpine and 22-slim node js images. It seems the latest push (about 24 hours ago) has produced errors when using googleapis (sheets, trace API, possibly others). I've been able to rep...
Open Graph Description: We ran into an issue with our deployments using the 22-alpine and 22-slim node js images. It seems the latest push (about 24 hours ago) has produced errors when using googleapis (sheets, trace API,...
X Description: We ran into an issue with our deployments using the 22-alpine and 22-slim node js images. It seems the latest push (about 24 hours ago) has produced errors when using googleapis (sheets, trace API,...
Opengraph URL: https://github.com/nodejs/docker-node/issues/2544
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Requests to google apis failing with `Premature close` on 22.23.0 tags","articleBody":"We ran into an issue with our deployments using the `22-alpine` and `22-slim` node js images. It seems the latest push (about 24 hours ago) has produced errors when using googleapis (sheets, trace API, possibly others).\n\nI've been able to reproduce by using the basic quickstart to read from a sheet https://developers.google.com/workspace/sheets/api/quickstart/nodejs#set_up_the_sample (it requires setting up credentials, so I can't provide a simple repo with reproduction.\n\nI'm not sure if this is an issue in the base image or in some random dependency, so direct me if this should be raised elsewhere.\n\n## Environment\n\n* **Platform**: Linux\n* **Docker Version**: 29.5.2\n* **Node.js Version**: v22.23.0\n* **Image Tag**: [22-slim](https://hub.docker.com/layers/library/node/22-slim/images/sha256-dc73bdac873c82e6cbfa496e35dd6e27a20302ebba043d0d9646708df19a9996) (`22-alpine` is also affected, `22` also fails)\n\n## Expected Behavior\n\nThe googleapis calls should just work, like on the previous image version.\n\n## Current Behavior\n\nThe calls fail with:\n```\n/node_modules/node-fetch/lib/index.js:400\n\t\t\t\treject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err));\n\t\t\t\t ^\nFetchError: Invalid response body while trying to fetch https://www.googleapis.com/oauth2/v4/token: Premature close\n at Gunzip.\u003canonymous\u003e (/node_modules/node-fetch/lib/index.js:400:12)\n at Gunzip.emit (node:events:531:35)\n at emitErrorNT (node:internal/streams/destroy:170:8)\n at emitErrorCloseNT (node:internal/streams/destroy:129:3)\n at process.processTicksAndRejections (node:internal/process/task_queues:89:21)\n```\n\n## Possible Solution\n\nRolling back to previous version of the image is a workaround, but I'm not sure where the exact issue lies. It might be in the alpine base.\n\n## Steps to Reproduce\n\nSetup the [exmaple](https://developers.google.com/workspace/sheets/api/quickstart/nodejs#set_up_the_sample) google sheet reading node js app:\n - `npm init -y`\n - `npm install googleapis@105 @google-cloud/local-auth@2.1.0 --save`\n - Get credentials by creating an app (or if you have a Google Cloud Project those can be used as well)\n - Setup Dockerfile with node:22-slim (see below)\n - Run the script via docker\n\nMy `index.js` (using Google Cloud Project credentials):\n```js\nimport { GoogleAuth } from 'google-auth-library';\nimport {google} from 'googleapis';\n\n/**\n * Prints the names and majors of students in a sample spreadsheet:\n * @see https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit\n */\nasync function listMajors() {\n // Authenticate with Google and get an authorized client.\n // const auth = await authenticate({\n // scopes: SCOPES,\n // keyfilePath: CREDENTIALS_PATH,\n // });\n\n const auth = new GoogleAuth({\n scopes: 'https://www.googleapis.com/auth/spreadsheets',\n });\n\n // Create a new Sheets API client.\n const sheets = google.sheets({version: 'v4', auth});\n // Get the values from the spreadsheet.\n const result = await sheets.spreadsheets.values.get({\n spreadsheetId: '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms',\n range: 'Class Data!A2:E',\n });\n const rows = result.data.values;\n if (!rows || rows.length === 0) {\n console.log('No data found.');\n return;\n }\n console.log('Name, Major:');\n // Print the name and major of each student.\n rows.forEach((row) =\u003e {\n // Print columns A and E, which correspond to indices 0 and 4.\n console.log(`${row[0]}, ${row[4]}`);\n });\n}\n\nawait listMajors();\n```\n\nDockerfile\n```Dockerfile\nFROM node:22-slim\n\nCOPY . .\nRUN npm install\nENV GOOGLE_APPLICATION_CREDENTIALS=./credentials.json\n\nCMD [\"node\", \"index.js\"]\n```\n`docker run --rm -it $(docker build -q .)` then results in `FetchError: Invalid response body while trying to fetch https://www.googleapis.com/oauth2/v4/token: Premature close`\n\nRolling the image to https://hub.docker.com/layers/library/node/22.22-slim/images/sha256-16d364eebf6b62da439dc993d9b80940c78b0ca38438452f011ab9a25c752644 is a possible fix, since in that version it just works.\n\nWorking Dockerfile with pinned version:\n```Dockerfile\nFROM node:22-slim@[e21fc383b50d5347dc7a9f1cae45b8f4e2f0d39f7ade28e4eef7d2934522b752](sha256:e21fc383b50d5347dc7a9f1cae45b8f4e2f0d39f7ade28e4eef7d2934522b752)\n\nCOPY . .\nRUN npm install\nENV GOOGLE_APPLICATION_CREDENTIALS=./credentials.json\n\nCMD [\"node\", \"index.js\"]\n```\n","author":{"url":"https://github.com/tomaskallup","@type":"Person","name":"tomaskallup"},"datePublished":"2026-06-19T16:34:44.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/2544/docker-node/issues/2544"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4f40ad6d-3559-ae20-6dcc-cb77e9e3ff91 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B466:312530:196B85E:23A4C7B:6A4CC05F |
| html-safe-nonce | e264335cb33f6f15c122f8e50f4c1999b0704d902c5e0a3da61395a75a38ffb9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDY2OjMxMjUzMDoxOTZCODVFOjIzQTRDN0I6NkE0Q0MwNUYiLCJ2aXNpdG9yX2lkIjoiNjQ5MzgxNjQ4NjkwMDg0MjU5MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | db3d27f19cf6ee16639c8f97d96dafe2e12e371df1af7b32a24dbe2ad4d2b354 |
| hovercard-subject-tag | issue:4702234591 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/docker-node/2544/issue_layout |
| twitter:image | https://opengraph.githubassets.com/adafbebf604515da6b0209aca43f9bc204d8ed6be62ed8c92e8400b5a8a565af/nodejs/docker-node/issues/2544 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/adafbebf604515da6b0209aca43f9bc204d8ed6be62ed8c92e8400b5a8a565af/nodejs/docker-node/issues/2544 |
| og:image:alt | We ran into an issue with our deployments using the 22-alpine and 22-slim node js images. It seems the latest push (about 24 hours ago) has produced errors when using googleapis (sheets, trace API,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tomaskallup |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/docker-node git https://github.com/nodejs/docker-node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27929056 |
| octolytics-dimension-repository_nwo | nodejs/docker-node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27929056 |
| octolytics-dimension-repository_network_root_nwo | nodejs/docker-node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c03e7e569190bc89b638cdd4acb4b6c6b38a170a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width