firebase-admin-node icon indicating copy to clipboard operation
firebase-admin-node copied to clipboard

[Firestore] RangeError thrown on Node version 22.7.0

Open vladmashk opened this issue 1 year ago • 4 comments

  • Operating System version: Windows 11, macOS Sonoma 14.6.1
  • Firebase SDK version: [email protected]
  • Firebase Product: Firestore
  • Node.js version: 22.7.0
  • NPM version: 10.8.2

Description of the problem

Accessing the firestore API throws a RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: "length" is outside of buffer bounds

Steps to reproduce:

Any access like: const snapshot = await db.collection("...").get(); for example throws this error.

This problem didn't happen on Node 22.4.0.

Stack trace

RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: "length" is outside of buffer bounds
    at proto.utf8Write (node:internal/buffer:1066:13)
    at Op.writeStringBuffer [as fn] (C:\path\to\package\node_modules\protobufjs\src\writer_buffer.js:61:13)
    at BufferWriter.finish (C:\path\to\package\node_modules\protobufjs\src\writer.js:453:14)
    at C:\path\to\package\node_modules\@grpc\proto-loader\build\src\index.js:177:109
    at Array.map (<anonymous>)
    at createPackageDefinition (C:\path\to\package\node_modules\@grpc\proto-loader\build\src\index.js:177:39)
    at Object.fromJSON (C:\path\to\package\node_modules\@grpc\proto-loader\build\src\index.js:230:12)
    at GrpcClient.loadProtoJSON (C:\path\to\package\node_modules\google-gax\build\src\grpc.js:228:51)
    at new LocationsClient (C:\path\to\package\node_modules\google-gax\build\src\locationService.js:118:32)
    at new FirestoreClient (C:\path\to\package\node_modules\@google-cloud\firestore\build\src\v1\firestore_client.js:136:32)
Caused by: Error
    at QueryUtil._getResponse (C:\path\to\package\node_modules\@google-cloud\firestore\build\src\reference\query-util.js:42:23)
    at CollectionReference._getResponse (C:\path\to\package\node_modules\@google-cloud\firestore\build\src\reference\query.js:792:32)
    at CollectionReference._get (C:\path\to\package\node_modules\@google-cloud\firestore\build\src\reference\query.js:785:35)
    at CollectionReference.get (C:\path\to\package\node_modules\@google-cloud\firestore\build\src\reference\query.js:754:39)
    at <my code>

vladmashk avatar Aug 27 '24 14:08 vladmashk

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Aug 27 '24 14:08 google-oss-bot

The problem also doesn't happen on Node 22.6.0

vladmashk avatar Aug 27 '24 14:08 vladmashk

This might be happening in bun as well, where db.collection("...").get(); returns an inconsistent number of docs whenever it's run.

dancamdev avatar Aug 27 '24 15:08 dancamdev

downgrading to node v20 fixed the issue

anasmohammed361 avatar Aug 28 '24 03:08 anasmohammed361

Hey folks, this is due to a bug in Node v22.7.0 https://github.com/nodejs/node/issues/54518

It should be fixed in v22.8.0, which they plan to release next week https://github.com/nodejs/node/pull/54560#issuecomment-2318836543

I am closing this issue since this does not require any changes to the SDK.

lahirumaramba avatar Aug 30 '24 17:08 lahirumaramba

Hey folks, this is due to a bug in Node v22.7.0 nodejs/node#54518

It should be fixed in v22.8.0, which they plan to release next week nodejs/node#54560 (comment)

I am closing this issue since this does not require any changes to the SDK.

wow thanks.

expertzz avatar Sep 28 '24 15:09 expertzz