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

Bug: Constructor shouldn't call async function #58

Open
sondreb opened this issue Jul 24, 2023 · 0 comments
Open

Bug: Constructor shouldn't call async function #58

sondreb opened this issue Jul 24, 2023 · 0 comments

Comments

@sondreb
Copy link

sondreb commented Jul 24, 2023

The constructor performs a call to an async function and assigns the callback handler to the array, which is suppose to be populated with the "op" object and not the callback function itself.

generateOperation is an async method, but it's called in constructor (which can't be async):

  constructor(options = { }) {
    this.#ops = options.ops || [ ];
    this.#generateKeyPair = options.generateKeyPair || generateKeyPair;
    if (!this.#ops.length) {
      this.#ops.push(this.generateOperation('create', options.content || { }, false));
    }
  }

Since it's a callback reference and not the actual operation data, the previous field on second operation becomes a ZoneAwarePromise instead of the operation data.

previous: ZoneAwarePromise

This results in serialization of the state not being correct.

This can probably only be solved by removing this default create operation and requiring the library consumer to call some "create" method instead.

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

1 participant