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

Include field and type name in toBinary errors? #983

Open
bhollis opened this issue Oct 3, 2024 · 1 comment · May be fixed by #984
Open

Include field and type name in toBinary errors? #983

bhollis opened this issue Oct 3, 2024 · 1 comment · May be fixed by #984

Comments

@bhollis
Copy link
Contributor

bhollis commented Oct 3, 2024

Would folks be open to adding more information to errors returned from toBinary? For example, right now I'm getting this error:

Error: invalid uint32: -1
    at assertUInt32 (file:///home/node/app/node_modules/.pnpm/@[email protected]/node_modules/@bufbuild/protobuf/dist/esm/wire/binary-encoding.js:487:15)
    at BinaryWriter.uint32 (file:///home/node/app/node_modules/.pnpm/@[email protected]/node_modules/@bufbuild/protobuf/dist/esm/wire/binary-encoding.js:161:9)
    at writeScalarValue (file:///home/node/app/node_modules/.pnpm/@[email protected]/node_modules/@bufbuild/protobuf/dist/esm/to-binary.js:164:20)
    at writeScalar (file:///home/node/app/node_modules/.pnpm/@[email protected]/node_modules/@bufbuild/protobuf/dist/esm/to-binary.js:71:5)
    at writeField (file:///home/node/app/node_modules/.pnpm/@[email protected]/node_modules/@bufbuild/protobuf/dist/esm/to-binary.js:55:13)
    at writeFields (file:///home/node/app/node_modules/.pnpm/@[email protected]/node_modules/@bufbuild/protobuf/dist/esm/to-binary.js:38:9)
    at writeMessageField (file:///home/node/app/node_modules/.pnpm/@[email protected]/node_modules/@bufbuild/protobuf/dist/esm/to-binary.js:78:9)
    at writeField (file:///home/node/app/node_modules/.pnpm/@[email protected]/node_modules/@bufbuild/protobuf/dist/esm/to-binary.js:61:13)

I can't tell which field was being written, or which message type. If we added a try/catch around writeField we could add this information. I'm happy to submit a PR if this is something folks want.

@timostamm
Copy link
Member

Hey Ben, it would be nice to provide more context in those errors if we can avoid regressions on performance, and keep bundle size reasonable.

It's not as simple as catching everything in writeField though, since it's called recursively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants