feathersjs-ecosystem / feathers-sync

Synchronize service events between Feathers application instances
MIT License
221 stars 41 forks source link

bson - cyclic dependency detected #168

Closed ranhsd closed 1 year ago

ranhsd commented 2 years ago

Hi, I integrated feathers-sync to my backend and everything works find except the moment that I want to create a new user. When I am trying to create a new user, I am getting the following error from bson serializer:

image

I tried to remove the serializer and it worked but I need it for other real time events that I have on my backend.

BTW! the user is created successfully on the backend but I get this 500 error from the rest api each time I am trying to create a new user.

Does anyone know what can be the issue?

I am using Feathers 4.5.11 and the users are being stored in MongoDB for that I am using the feathers-mongoose module

Thanks, Ran.

daffl commented 2 years ago

You will have to resolve cyclical dependencies with your own custom serializer as described in https://github.com/feathersjs-ecosystem/feathers-sync#custom-serializer--deserializer

ranhsd commented 2 years ago

Hi @daffl thanks for your quick answer.

In my code I use the following:

app.configure(sync({ uri: 'redis://process.env..REDIS_HOST:6379', redisOptions: { return_buffers: true }, serialize: bson.serialize, deserialize: bson.deserialize, }));

so I actually do use the bson custom serialization do I need to create my own serialization based on bson or bson should be fine?

I am asking because when I use bson I get the cycle error

Thanks, Ran.

daffl commented 2 years ago

What I mean is that it is up to you to resolve cyclical dependencies before calling the serializer. Usually this error happens when trying to serialize ORM model instances so you'd e.g. have to call .toJSON on it.