Skip to content

Buffer bounds problem with logging-winston (maybe logging generally) on node v22.7 #850

@circle-eric

Description

@circle-eric

The google cloud sdk image we are using runs the latest version of node, it appears there is an issue with logging on this version of node. Image crashes on startup and breaks deploy.

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] (/workspace/node_modules/protobufjs/src/writer_buffer.js:61:13)
    at BufferWriter.finish (/workspace/node_modules/protobufjs/src/writer.js:453:14)
    at /workspace/node_modules/@grpc/proto-loader/build/src/index.js:152:109
    at Array.map (<anonymous>)
    at createPackageDefinition (/workspace/node_modules/@grpc/proto-loader/build/src/index.js:152:39)
    at Object.fromJSON (/workspace/node_modules/@grpc/proto-loader/build/src/index.js:205:12)
    at GrpcClient.loadProtoJSON (/workspace/node_modules/google-gax/build/src/grpc.js:228:51)
    at new ConfigServiceV2Client (/workspace/node_modules/@google-cloud/logging/build/src/v2/config_service_v2_client.js:136:38)
    at new Logging (/workspace/node_modules/@google-cloud/logging/build/src/index.js:140:30)
    at new LoggingCommon (/workspace/node_modules/@google-cloud/logging-winston/build/src/common.js:94:29)
    at new LoggingWinston (/workspace/node_modules/@google-cloud/logging-winston/build/src/index.js:113:23)

Environment details

  • OS: debian (google/cloud-sdk:latest)

  • Node.js version: v22.7.0

  • @google-cloud/logging-winston version: "^6.0.0"

Steps to reproduce

It doesn't seems like there is just a problem with node 22.7 and some dependency used by logging. The following example:

package.json

  {
  "name": "test_logging_pkg",
  "version": "1.0.0",
  "main": "test.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "description": "",
  "dependencies": {
    "@google-cloud/logging-winston": "^6.0.0"
  }
}

test.js

const { LoggingWinston } = require('@google-cloud/logging-winston');

new LoggingWinston();

Will crash with

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

Metadata

Metadata

Assignees

Labels

api: loggingIssues related to the googleapis/nodejs-logging-winston API.priority: p3Desirable enhancement or fix. May not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions