Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
circle-eric opened this issue Aug 26, 2024 · 3 comments
Assignees
Labels
api: logging Issues related to the googleapis/nodejs-logging-winston API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@circle-eric
Copy link

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'
}
@circle-eric circle-eric added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Aug 26, 2024
@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/nodejs-logging-winston API. label Aug 26, 2024
@jerryjj
Copy link

jerryjj commented Aug 27, 2024

Can replicate on alpine also, suddenly all staging deployments to Cloud Run started to break which uses the "node:22-alpine" Docker base image

@jerryjj
Copy link

jerryjj commented Aug 27, 2024

Just to mention here, other libraries are also affected with the same bug. Seems to be issue with NodeJS itself nodejs/node#54518

@cindy-peng
Copy link
Contributor

Hi @jerryjj , it looks like this issue has been fixed for NodeJS in the latest version v22.8.0: nodejs/node#54518 (comment)

Are you still running into this issue?

@cindy-peng cindy-peng added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/nodejs-logging-winston API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants