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

New Enum breakage in static code. #641

Closed
ehallander9591 opened this issue Jan 12, 2017 · 4 comments
Closed

New Enum breakage in static code. #641

ehallander9591 opened this issue Jan 12, 2017 · 4 comments
Labels

Comments

@ehallander9591
Copy link

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;
                                }
                                break;
<please paste the stack trace of the error if applicable>
@ehallander9591
Copy link
Author

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].ctor.prototype.toObject.call(message.unit, options);
                                }
                                break;

dcodeIO added a commit that referenced this issue Jan 12, 2017
…641; Fixed: Use Type.toObject/Message.toObject within converters, see #641
@dcodeIO dcodeIO added the bug label Jan 12, 2017
@dcodeIO
Copy link
Member

dcodeIO commented Jan 12, 2017

Always amazing how many stupid mistakes there are, still 😲

@ehallander9591
Copy link
Author

I'll check this out when I get home.

@ehallander9591
Copy link
Author

Looks good sir.

Thanks!!

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

No branches or pull requests

2 participants