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

'Error: not implemented' when using array .splice() to remove items (but not add any) #5

Closed
senseibaka opened this issue Nov 9, 2022 · 3 comments · Fixed by #6
Closed

Comments

@senseibaka
Copy link
Contributor

Repro:

Replace this line

d1.topping.splice(2, 2, { id: '7777', type: 'test1' }, { id: '8888', type: 'test2' })

with

d1.topping.splice(2, 2)

and then rerun the unit test

@senseibaka
Copy link
Contributor Author

I've been digging into this a little bit, immer seems to send:

  • [success] an array manipulation patch (i.e. remove items from the array)
  • [error] a property change patch which specifies the path length has changed value

I'd suggest doing something around https://github.com/sep2/immer-yjs/blob/main/packages/immer-yjs/src/immer-yjs.ts#L107

Like

} else if (base instanceof Y.Array && property === 'length') {
    // no-op
} else {
    notImplemented();
}

@sep2
Copy link
Owner

sep2 commented Nov 9, 2022

Thank you for reporting! I will investigate into it. At the same time PR is welcome 😁

@senseibaka
Copy link
Contributor Author

Thanks, if I get some time in the next few days I might work on it.

The problem is a little more complex by the way, I've observed in cases where you splice-remove the last item in an array, immer only supplies a patch for the changed length property, so the above suggestion wouldn't work in all cases.

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 a pull request may close this issue.

2 participants