fix: make port transferables unique#3421
Conversation
|
Thank you for submitting this PR!
Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment.
We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution. |
|
This looks great, thanks for submitting it. Please can you add a test to ensure regressions won't occur in future? |
6693663 to
1721825
Compare
|
@achingbrain I added a test for When the test is ran in the browser environment, it does complain about |
Gozala
left a comment
There was a problem hiding this comment.
Thanks @icidasset for identifying this issue and also fixing it! It looks good. There would be few nice to haves, but I would much rather land this now and address them in followups. Feel free to take a stab if you like, otherwise I'll do it when I'll get around to it.
- Implement solution does more or less following
[...new Set(...transfer)]to eliminate duplicates. But ideally we would just maketransferitself into aSetso we don't have to eliminated duplicates. postMessageactually accepts Sets (or any iterable) for transfer list, so conversion back to array is unnecessary.- I think it would probably be better to amend
ipfs-message-port-protocoltests to exercise moving nodes e.g with duplicates CIDs.
@Gozala please can you open issues for the outstanding pieces of work so they don't get missed |
|
Fixes #3402
The
transferlist, ie. the second argument topostMessage, should always contain unique values, multiple of the same pointers cause errors. This PR fixes that, see linked issue above for more info. My solution was to just make everything in the list unique by converting the array to a set and back. Let me know if this works, or if another solution is preferred.