moleculerjs / moleculer

:rocket: Progressive microservices framework for Node.js
https://moleculer.services/
MIT License
6.13k stars 581 forks source link

Bug(registry): serialize a BigInt in settings #807

Closed intech closed 3 years ago

intech commented 4 years ago

Prerequisites

Please answer the following questions for yourself before submitting an issue.

Reproduce code snippet

const { ServiceBroker } = require("moleculer");
const broker = new ServiceBroker();

broker.createService({
    name: "test",
    settings: {
      test: 16384n
    }
});

broker.start().catch(console.error);

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

Failure Logs

today at 01:51 [Runner] Do not know how to serialize a BigInt TypeError: Do not know how to serialize a BigInt
today at 01:51 at JSON.stringify (<anonymous>)
today at 01:51 at Object.safetyObject (/app/node_modules/moleculer/src/utils.js:350:26)
today at 01:51 at Registry.regenerateLocalRawInfo (/app/node_modules/moleculer/src/registry/registry.js:384:24)
today at 01:51 at /app/node_modules/moleculer/src/service-broker.js:457:19
today at 01:51 at processTicksAndRejections (internal/process/task_queues.js:93:5)
intech commented 4 years ago

Ref solution: https://github.com/GoogleChromeLabs/jsbi/issues/30#issuecomment-521460510