Skip to content

Serializer: name the packet in write errors from a compiled protocol - #180

Open
u9g wants to merge 1 commit into
ProtoDef-io:masterfrom
u9g:serializer-packet-name
Open

Serializer: name the packet in write errors from a compiled protocol#180
u9g wants to merge 1 commit into
ProtoDef-io:masterfrom
u9g:serializer-packet-name

Conversation

@u9g

@u9g u9g commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Problem

Every packet write goes through Serializer.createPacketBuffer, but a compiled protocol never sets e.field, so the errors coming out say nothing about which packet failed:

Error: Write error for undefined : Missing field 'x'
Error: SizeOf error for undefined : 0 is not in the mappings value

The interpreter names it through the switch's field path (params.position.face); the compiler reports no path at all. The error is thrown inside _transform and surfaces asynchronously on the stream, so a caller cannot attribute it after the fact either.

Change

Serializer.createPacketBuffer prefixes the message with in packet <name>: when the value has a name and the error's field path does not already contain it:

in packet position: SizeOf error for undefined : up is not in the mappings value

Interpreted errors and values without a name are untouched.

Testing

  • New tests in test/misc.js: compiled gets the prefix, interpreted keeps its field path with no duplicate, a value with no name is left alone.
  • npm test: lint clean, 504 passing.

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 this pull request may close these issues.

1 participant