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

Release 2.9.3 breaks serialization for me #616

Closed
KillingSpark opened this issue Dec 11, 2023 · 6 comments
Closed

Release 2.9.3 breaks serialization for me #616

KillingSpark opened this issue Dec 11, 2023 · 6 comments

Comments

@KillingSpark
Copy link

Hi,

I updated from version 2.9.1 to 2.9.3 which broke serialization for me. Specifically the change from:

    create(value?: PartialMessage<ApiMessage>): ApiMessage {
        const message = { message: { oneofKind: undefined } };
        globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this });
        // snip
        return message;
    }

to

    create(value?: PartialMessage<ApiMessage>): ApiMessage {
        const message = globalThis.Object.create(this.messagePrototype);
        // snip
        return message;
    }

seems to be the culprit, because this.messagePrototype seems to be undefined

@jcready
Copy link
Contributor

jcready commented Dec 11, 2023

Was the generated code using a newer version of the plugin/runtime (>2.9.1) than what you're using at runtime (<=2.9.1)? I had raised this concern in the PR where this change was introduced but I assumed that combination was rather unlikely.

@KillingSpark
Copy link
Author

I am pretty sure I was updating both runtime and the environment I was using to generate the code in lockstep. I will double check this tomorrow. If that actually is the issue that's my bad I definitely intended to update it in lockstep

@KillingSpark
Copy link
Author

Sorry for the bother, I noticed that I did in fact not propgate the update of the protobuf-ts/runtime to the correct subfolder. Works as expected with both generation and runtime on 2.9.3

@jcready
Copy link
Contributor

jcready commented Dec 12, 2023

One way to cover all the bases here would be for the generated code to also perform the Object.defineProperty() call in its constructor rather than rely on the runtime's MessageType constructor from which it inherits. Seeing as someone has already hit this supposed edge case it wouldn't be the worst solution to ensure it doesn't happen again.

@KillingSpark
Copy link
Author

I want to add that this was caused by our (I think) unusual way of structuring our repos. I do think that hitting this is in fact an edge case :)

@kayla-glick
Copy link

kayla-glick commented Mar 14, 2024

Hey @jcready I just ran into this issue today with a project I work on https://github.com/wowsims/sod after we upgraded from 2.9.1 to 2.9.4. I'm not 100% sure but I wonder if it's the backwards-compatibility issue you mentioned in your PR?

I also just wanted to add that downgrading back to 2.9.1 was a bit of work. In our package.json we had

"@protobuf-ts/plugin": "2.9.1",
"@protobuf-ts/runtime": "2.9.1",

but the @protobuf-ts/plugin-framework and @protobuf-ts/protoc dependencies didn't respect the version lock and were still using ^2.9.1 which installed 2.9.4 instead. We had to manually install these locked to 2.9.1

"@protobuf-ts/plugin": "2.9.1",
"@protobuf-ts/plugin-framework": "2.9.1",
"@protobuf-ts/protoc": "2.9.1",
"@protobuf-ts/runtime": "2.9.1",

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

No branches or pull requests

3 participants