moleculer-web icon indicating copy to clipboard operation
moleculer-web copied to clipboard

Action addRoute tries to serialize function

Open ghost opened this issue 3 years ago • 5 comments

I'm using the new gateway action addRoute and it seems to try to serialize a function, which is not a problem with JSON serializer, but with CBOR for example crashes the entire node. image image

ghost avatar Jan 24 '22 14:01 ghost

I think the issue is here: https://github.com/moleculerjs/moleculer-web/blob/master/src/index.js#L1177 where the entire route is returned with functions included...

giovanni-bertoncelli avatar Jan 24 '22 14:01 giovanni-bertoncelli

Hi @giovanni-bertoncelli can you please create a repro repo?

AndreMaz avatar Jan 25 '22 16:01 AndreMaz

We can't fix it. Related open issue in cbor repo: https://github.com/kriszyp/cbor-x/issues/2

icebob avatar Jan 25 '22 20:01 icebob

We have software in production that has migrated to the CBOR serializer... this bug can be very frustrating, can't this be fixed on the moleculer side or with a PR on cbor-x?

giovanni-bertoncelli avatar Feb 14 '22 11:02 giovanni-bertoncelli

Alternative, if you copy the CBOR serializer code and walk the payload in serialize method and remove functions. It beats the performance pretty well, this is why I don't do that in the built-in serializer. The eventual solution if it's fixed in CBOR lib.

icebob avatar Feb 19 '22 16:02 icebob