moleculerjs / moleculer-web

:earth_africa: Official API Gateway service for Moleculer framework
http://moleculer.services/docs/moleculer-web.html
MIT License
292 stars 118 forks source link

Action addRoute tries to serialize function #294

Open giovanni-bertoncelli opened 2 years ago

giovanni-bertoncelli commented 2 years ago

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

giovanni-bertoncelli commented 2 years ago

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...

AndreMaz commented 2 years ago

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

icebob commented 2 years ago

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

giovanni-bertoncelli commented 2 years ago

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?

icebob commented 2 years ago

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.