protobufjs / protobuf.js

Protocol Buffers for JavaScript & TypeScript.
Other
9.85k stars 1.41k forks source link

"length" is outside of buffer bounds #2025

Closed phaistonian closed 1 week ago

phaistonian commented 3 weeks ago

protobuf.js version: 7.4.0

It appears that the latest nodejs version (22.7.0) triggers this error:

RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: "length" is outside of buffer bounds

at

CleanShot 2024-08-23 at 09 21 15@2x

likezero commented 3 weeks ago

I have the same error image

markkkkas commented 3 weeks ago

We are observing same issue

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/node_modules/.pnpm/protobufjs@7.2.4/node_modules/protobufjs/src/writer_buffer.js:61:13)
    at BufferWriter.finish (/app/node_modules/.pnpm/protobufjs@7.2.4/node_modules/protobufjs/src/writer.js:453:14)
    at /app/node_modules/.pnpm/@grpc+proto-loader@0.7.6/node_modules/@grpc/proto-loader/build/src/index.js:152:109
    at Array.map (<anonymous>)
    at createPackageDefinition (/app/node_modules/.pnpm/@grpc+proto-loader@0.7.6/node_modules/@grpc/proto-loader/build/src/index.js:152:39)
    at Object.fromJSON (/app/node_modules/.pnpm/@grpc+proto-loader@0.7.6/node_modules/@grpc/proto-loader/build/src/index.js:205:12)
    at GrpcClient.loadProtoJSON (/app/node_modules/.pnpm/google-gax@4.0.3_encoding@0.1.13/node_modules/google-gax/build/src/grpc.js:228:51)
    at new TranslationServiceClient (/app/node_modules/.pnpm/@google-cloud+translate@8.3.0_encoding@0.1.13/node_modules/@google-cloud/translate/build/src/v3/translation_service_client.js:146:38)
    at new GoogleTranslationService (/app/apps/dist/lib/google-translation.js:55:32)

As a fix, we decided to downgrade node version (22.4.0 works fine).

cecilulysess commented 3 weeks ago

Same issue, not necessary to protobufjs@7.4. The error thrown on my 7.3.3

danielbankhead commented 3 weeks ago

This sounds like an upstream Node issue:

nextlevelshit commented 1 week ago

In case you are still experiencing that issues, try these LTS versions:

Everything above looks from my perspective broken and leads to these buffer errors.

mbrevda commented 1 week ago

Also fixed in the latest node (v22.8.0)

temirrr commented 3 days ago

@mbrevda thanks, upgrading to v22.8.0 worked for me