Compare socket event data using lodash's isEqual instead of indexOf #1061
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When running feathers-sync we had an issue with websockets being triggered with null values when bulk patching:
Without feathers-sync this will properly send out one socket event for each affected row in the
foo
service. However with feathers-sync active the sockets would instead be sent out withnull
as their data instead of the actual object.See issue previously reported and closes feathersjs-ecosystem/feathers-sync#96
Upon further investigation it seems the issue is not technically in feathers-sync but in transport-commons. The issue seems to be that
getDispatcher
usesindexOf
when trying to get individual item to dispatch. This normally works fine because the check thatindexOf
performs under the hood will check the reference and without feathers-sync the references will always match. However, the way feathers-sync works is that it willJSON.stringify
the object and thenJSON.parse
the object thus creating a new reference. SoindexOf
will then returnfalse
and no data will be found for the socket to emit.We fixed this by using lodash's
isEqual
with.find
to find the correct individual item to dispatch. In our limited testing this seems to fix the issue when running feathers-sync while not breaking anything when running without feathers-sync.