[GH-ISSUE #529] Can't download files with v5.8.2+ of the Node.js client #100

Closed
opened 2026-03-03 12:08:16 +03:00 by kerem · 1 comment
Owner

Originally created by @gnarea on GitHub (Jul 9, 2021).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/529

Version 5.8.1 of the Node.js client works fine, but versions 5.8.2 to 5.8.5 (latest) don't.

I suspect https://github.com/googleapis/nodejs-storage/pull/1419 is the culprit, but that must obviously be working against GCS servers.

Here's a simple repro script:

test('Bug', async () => {
  const bucketName = 'foo';
  const fileContents = Buffer.from('bar');

  const client = new Storage({
    apiEndpoint: 'http://127.0.0.1:8080',
    projectId: 'the id',
  });

  await client.createBucket(bucketName);

  const file = client.bucket(bucketName).file('key');
  await file.save(fileContents, { resumable: false });

  const [fileRetrievalResponse] = await file.get();
  await expect(fileRetrievalResponse.download()).resolves.toEqual([fileContents]);
});

fileRetrievalResponse.download() fails with:

Error: The downloaded data did not match the data from the server. To be sure the content is the same, you should download the file again.

Server logs:

gcs_1    | time="2021-07-09T15:25:12Z" level=info msg="couldn't load any objects or buckets from \"/data\", starting empty"
gcs_1    | time="2021-07-09T15:25:12Z" level=info msg="server started at http://[::]:8080"
gcs_1    | time="2021-07-09T15:25:18Z" level=info msg="172.30.0.1 - - [09/Jul/2021:15:25:18 +0000] \"POST /storage/v1/b?project=the%20id HTTP/1.1\" 200 110"
gcs_1    | time="2021-07-09T15:25:18Z" level=info msg="172.30.0.1 - - [09/Jul/2021:15:25:18 +0000] \"POST /upload/storage/v1/b/foo/o?uploadType=multipart&name=key HTTP/1.1\" 200 357"
gcs_1    | time="2021-07-09T15:25:18Z" level=info msg="172.30.0.1 - - [09/Jul/2021:15:25:18 +0000] \"GET /storage/v1/b/foo/o/key? HTTP/1.1\" 200 400"
gcs_1    | time="2021-07-09T15:25:18Z" level=info msg="172.30.0.1 - - [09/Jul/2021:15:25:18 +0000] \"GET /storage/v1/b/foo/o/key?alt=media HTTP/1.1\" 200 3"
gcs_1    | time="2021-07-09T15:25:18Z" level=info msg="172.30.0.1 - - [09/Jul/2021:15:25:18 +0000] \"GET /storage/v1/b/foo/o/key? HTTP/1.1\" 200 400"

I've tested this against versions 1.21.2 and 1.28 of the fake-gcs-server.

Originally created by @gnarea on GitHub (Jul 9, 2021). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/529 Version 5.8.1 of the Node.js client works fine, but versions 5.8.2 to 5.8.5 (latest) don't. I suspect https://github.com/googleapis/nodejs-storage/pull/1419 is the culprit, but that must obviously be working against GCS servers. Here's a simple repro script: ```typescript test('Bug', async () => { const bucketName = 'foo'; const fileContents = Buffer.from('bar'); const client = new Storage({ apiEndpoint: 'http://127.0.0.1:8080', projectId: 'the id', }); await client.createBucket(bucketName); const file = client.bucket(bucketName).file('key'); await file.save(fileContents, { resumable: false }); const [fileRetrievalResponse] = await file.get(); await expect(fileRetrievalResponse.download()).resolves.toEqual([fileContents]); }); ``` `fileRetrievalResponse.download()` fails with: ``` Error: The downloaded data did not match the data from the server. To be sure the content is the same, you should download the file again. ``` Server logs: ``` gcs_1 | time="2021-07-09T15:25:12Z" level=info msg="couldn't load any objects or buckets from \"/data\", starting empty" gcs_1 | time="2021-07-09T15:25:12Z" level=info msg="server started at http://[::]:8080" gcs_1 | time="2021-07-09T15:25:18Z" level=info msg="172.30.0.1 - - [09/Jul/2021:15:25:18 +0000] \"POST /storage/v1/b?project=the%20id HTTP/1.1\" 200 110" gcs_1 | time="2021-07-09T15:25:18Z" level=info msg="172.30.0.1 - - [09/Jul/2021:15:25:18 +0000] \"POST /upload/storage/v1/b/foo/o?uploadType=multipart&name=key HTTP/1.1\" 200 357" gcs_1 | time="2021-07-09T15:25:18Z" level=info msg="172.30.0.1 - - [09/Jul/2021:15:25:18 +0000] \"GET /storage/v1/b/foo/o/key? HTTP/1.1\" 200 400" gcs_1 | time="2021-07-09T15:25:18Z" level=info msg="172.30.0.1 - - [09/Jul/2021:15:25:18 +0000] \"GET /storage/v1/b/foo/o/key?alt=media HTTP/1.1\" 200 3" gcs_1 | time="2021-07-09T15:25:18Z" level=info msg="172.30.0.1 - - [09/Jul/2021:15:25:18 +0000] \"GET /storage/v1/b/foo/o/key? HTTP/1.1\" 200 400" ``` I've tested this against versions 1.21.2 and 1.28 of the `fake-gcs-server`.
kerem 2026-03-03 12:08:16 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@jdleesmiller commented on GitHub (Jul 13, 2021):

Note: https://github.com/fsouza/fake-gcs-server/pull/530 aims to fix this.

<!-- gh-comment-id:878997184 --> @jdleesmiller commented on GitHub (Jul 13, 2021): Note: https://github.com/fsouza/fake-gcs-server/pull/530 aims to fix this.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/fake-gcs-server#100
No description provided.