Closed apmcodes closed 4 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Apologies if the issue could not be resolved. FeathersJS ecosystem modules are community maintained so there may be a chance that there isn't anybody available to address the issue at the moment. For other ways to get help see here.
I have a similar issue...
Unhandled Rejection at: Promise [object Promise], TypeError: Converting circular structure to JSON
--> starting at object with constructor 'ClientRequest'
| property 'socket' -> object with constructor 'TLSSocket'
--- property '_httpM...
Same here.
We also facing what is the reason for the issue? Do need to fix anything on data side?
Do we need to use Custom Serializer / Deserializer?
Could some one help?
You just have to make sure that none of your data in the context contain a circular reference. A custom serializer is one option to ensure that, another is to make sure that all params
, result
or data
properties are serializable or serialized (e.g. with their toJSON
methods).
Module version:
"feathers-mongoose": "7.3.1",
"feathers-sync": "2.1.0",
"flatted": "3.0.4"
params structure in context:
params: {
mongoose: session
}
feather-sync configuration:
app.configure( sync({
uri: `<URL>`,
serialize: stringify, // stringify method from flatted package
deserialize: parse, // parse method from flatted package
}));
I am using feathers mongoose adapter and feathers sync. I have to pass the session in the context to achieve the transaction. which has a circular reference. I used flatted package to avoid converting the circular structure to JSON issue. After the deserialized context from feathers-sync creates session.isTransaction is not a function issue in mongoose library. Is there any other way to store context contain a circular reference like above to achieve sync?
You have to remove the session from the parameters once you used it where it is needed. It is not possible to pass the same session across different instance and it shouldn't be used in an event handler since it should not modify data as described in the caveats section.
thanks @daffl
I had this issue when I was passing sequelize includes across feathers-sync. A simple fix was to use flatted
as the serializer as it can serialize objects with circular references.
import {parse, stringify} from 'flatted';
app.configure(sync({
uri: app.get('redis'),
serialize: stringify,
deserialize: parse
}))
Getting the below error since may be after the recent feathers lib update. The error appears randomly at the end of different services. Error goes away on disabling events (as of now app wide) using
context.event = null;
Module versions (especially the part that's not working):
NodeJS version: v12.13.0
Not sure if my code is triggering this. Unable to understand as the code was working fine earlier.