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 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.
I'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.
Environment
- Platform: Linux
- Docker Version: 29.5.2
- Node.js Version: v22.23.0
- Image Tag: 22-slim (
22-alpine is also affected, 22 also fails)
Expected Behavior
The googleapis calls should just work, like on the previous image version.
Current Behavior
The calls fail with:
/node_modules/node-fetch/lib/index.js:400
reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err));
^
FetchError: Invalid response body while trying to fetch https://www.googleapis.com/oauth2/v4/token: Premature close
at Gunzip.<anonymous> (/node_modules/node-fetch/lib/index.js:400:12)
at Gunzip.emit (node:events:531:35)
at emitErrorNT (node:internal/streams/destroy:170:8)
at emitErrorCloseNT (node:internal/streams/destroy:129:3)
at process.processTicksAndRejections (node:internal/process/task_queues:89:21)
Possible Solution
Rolling 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.
Steps to Reproduce
Setup the exmaple google sheet reading node js app:
npm init -y
npm install googleapis@105 @google-cloud/local-auth@2.1.0 --save
- Get credentials by creating an app (or if you have a Google Cloud Project those can be used as well)
- Setup Dockerfile with node:22-slim (see below)
- Run the script via docker
My index.js (using Google Cloud Project credentials):
import { GoogleAuth } from 'google-auth-library';
import {google} from 'googleapis';
/**
* Prints the names and majors of students in a sample spreadsheet:
* @see https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit
*/
async function listMajors() {
// Authenticate with Google and get an authorized client.
// const auth = await authenticate({
// scopes: SCOPES,
// keyfilePath: CREDENTIALS_PATH,
// });
const auth = new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/spreadsheets',
});
// Create a new Sheets API client.
const sheets = google.sheets({version: 'v4', auth});
// Get the values from the spreadsheet.
const result = await sheets.spreadsheets.values.get({
spreadsheetId: '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms',
range: 'Class Data!A2:E',
});
const rows = result.data.values;
if (!rows || rows.length === 0) {
console.log('No data found.');
return;
}
console.log('Name, Major:');
// Print the name and major of each student.
rows.forEach((row) => {
// Print columns A and E, which correspond to indices 0 and 4.
console.log(`${row[0]}, ${row[4]}`);
});
}
await listMajors();
Dockerfile
FROM node:22-slim
COPY . .
RUN npm install
ENV GOOGLE_APPLICATION_CREDENTIALS=./credentials.json
CMD ["node", "index.js"]
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
Rolling 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.
Working Dockerfile with pinned version:
FROM node:22-slim@[e21fc383b50d5347dc7a9f1cae45b8f4e2f0d39f7ade28e4eef7d2934522b752](sha256:e21fc383b50d5347dc7a9f1cae45b8f4e2f0d39f7ade28e4eef7d2934522b752)
COPY . .
RUN npm install
ENV GOOGLE_APPLICATION_CREDENTIALS=./credentials.json
CMD ["node", "index.js"]
We ran into an issue with our deployments using the
22-alpineand22-slimnode 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 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.
I'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.
Environment
22-alpineis also affected,22also fails)Expected Behavior
The googleapis calls should just work, like on the previous image version.
Current Behavior
The calls fail with:
Possible Solution
Rolling 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.
Steps to Reproduce
Setup the exmaple google sheet reading node js app:
npm init -ynpm install googleapis@105 @google-cloud/local-auth@2.1.0 --saveMy
index.js(using Google Cloud Project credentials):Dockerfile
docker run --rm -it $(docker build -q .)then results inFetchError: Invalid response body while trying to fetch https://www.googleapis.com/oauth2/v4/token: Premature closeRolling 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.
Working Dockerfile with pinned version: