googleapis / nodejs-logging

Node.js client for Stackdriver Logging: Store, search, analyze, monitor, and alert on log data and events from Google Cloud Platform and Amazon Web Services (AWS).
https://cloud.google.com/logging/
Apache License 2.0
173 stars 63 forks source link

Constructor fails with "RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: "length" is outside of buffer bounds" #1520

Closed carusooo closed 2 months ago

carusooo commented 2 months ago

1) Is this a client library issue or a product issue? Client library

2) Did someone already solve this? No

3) Do you have a support contract? Yes, but filing here for others visibility

Environment details

Steps to reproduce

  1. Create an instance of the client like so
      const logging = new Logging();
      const log = logging.log('my-server', {
        maxEntrySize: 100000,
      });
  2. The following stack trace is thrown

    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] (/app/backend/node_modules/protobufjs/src/writer_buffer.js:61:13)
    at BufferWriter.finish (/app/backend/node_modules/protobufjs/src/writer.js:453:14)
    at /app/backend/node_modules/@grpc/proto-loader/build/src/index.js:177:109
    at Array.map (<anonymous>)
    at createPackageDefinition (/app/backend/node_modules/@grpc/proto-loader/build/src/index.js:177:39)
    at Object.fromJSON (/app/backend/node_modules/@grpc/proto-loader/build/src/index.js:230:12)
    at GrpcClient.loadProtoJSON (/app/backend/node_modules/google-gax/build/src/grpc.js:228:51)
    at new ConfigServiceV2Client (/app/backend/node_modules/@google-cloud/logging/build/src/v2/config_service_v2_client.js:136:38)
    at new Logging (/app/backend/node_modules/@google-cloud/logging/build/src/index.js:140:30)

This was working earlier today 22 Aug 2024 6p PDT, and began failing with builds created around 22 Aug 2024 9p PDT which leads me to believe that some change in an underlying library caused this issue.

carusooo commented 2 months ago

I retried with smaller values for maxEntrySize 5000, and without supplying it at all and still got the same error

carusooo commented 2 months ago

Some additional data points, this affects multiple GCP node libraries (including secretManager) and appears to be in this code block where the protos are loaded from the server (I am guessing?) where the code hasn't changed in 5 years

carusooo commented 2 months ago

This is due to a nodeJS issue with 22.7.0