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

New Enum breakage in static code. #641

ehallander9591 opened this Issue Jan 12, 2017 · 4 comments


None yet
2 participants

ehallander9591 commented Jan 12, 2017

protobuf.js version: 6.5.0

After pulling the latest from git, I find that the generated static code is referencing 'values' while trying to resolve the numeric part of an enum.

In the code below types[2].values should simply be types[2][message.changeType]

                            case "changeType":
                                if (message.changeType !== undefined && message.changeType !== null) {
                                    object.changeType = options.enums === String ? types[2].values[message.changeType] : message.changeType;
<please paste the stack trace of the error if applicable>

This comment has been minimized.

ehallander9591 commented Jan 12, 2017

Getting more than that. Sorry

TypeError: Cannot read property 'prototype' of undefined
    at Function.toObject (C:\Users\eric_hallander\git\MPXSCore\srcGen\js\mpxsStaticModule.js:10757:65)
    at PublishedMessage.toJSON (C:\Users\eric_hallander\git\MPXSCore\srcGen\js\mpxsStaticModule.js:10809:49)
    at Object.stringify (native)
    at Object.stringify (C:\Users\eric_hallander\git\MPXSCore\tsapp\fw\util.ts:96:14)
    at MpxsSessionManagerImpl.sendSocket (C:\Users\eric_hallander\git\MPXSCore\tsapp\MpxsServer.ts:218:50)
    at PublishSubscribeAdapter.socket.on (C:\Users\eric_hallander\git\MPXSCore\tsapp\mpxs\PublishSubscribeAdapter.ts:52:25)
    at emitOne (events.js:96:13)
    at emit (events.js:188:7)
    at Socket._flushRead (C:\Users\eric_hallander\git\MPXSCore\node_modules\zmq\lib\index.js:636:10)
    at Socket._flushReads (C:\Users\eric_hallander\git\MPXSCore\node_modules\zmq\lib\index.js:676:23)

and when I look at the generated code for this one

                            case "unit":
                                if (message.unit !== undefined && message.unit !== null) {
                                    object.unit = types[12], options);

dcodeIO added a commit that referenced this issue Jan 12, 2017

CLI: Replace all occurencies of types[%d].values in static code, see #…
…641; Fixed: Use Type.toObject/Message.toObject within converters, see #641

@dcodeIO dcodeIO added the bug label Jan 12, 2017


This comment has been minimized.


dcodeIO commented Jan 12, 2017

Always amazing how many stupid mistakes there are, still 😲


This comment has been minimized.

ehallander9591 commented Jan 12, 2017

I'll check this out when I get home.


This comment has been minimized.

ehallander9591 commented Jan 13, 2017

Looks good sir.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment