metacom icon indicating copy to clipboard operation
metacom copied to clipboard

Error on a server-side system.introspect() call

Open muturgan opened this issue 3 years ago • 1 comments

Project description

  • The first service is a metarhia/example fork. I don't know if it matters but it have not a "balancer" field at the server.js config and listening only one port (8002 for further clarity). The method promo/test was added there. It is very simple (does not matter):
({
  access: 'public',

  returns: 'string',

  method: () => {
    return 'Nice!';
  },
});
  • The second service is a metarhia/example fork. It also contains a new domain/mc.js file:
({
  mc: new metarhia.metacom.Metacom('ws://localhost:8002/api'),

  async test() {
    await this.mc.load('system');
    const api = this.mc.api;
    console.log(api); // { system: { introspect: [AsyncFunction (anonymous)] } }
    await api.system.introspect();
    return 'res';
  }
});
  • Also the second service contains a promo/test method too:
({
  access: 'public',

  returns: 'string',

  method: async () => {
    const res = await domain.mc.test();
    return res;
  },
});

Bug description And now when I make a second service promo/test call I get an error. The first service logs (looks like a key thing):

22:07:26  W1   error   127.0.0.1	GET	/api	500	TypeError: interfaces is not iterable
  Application.introspect (/node_modules/impress/lib/application.js:184:33)
  application.introspect (/node_modules/impress/lib/application.js:115:57)
  Procedure.invoke (/node_modules/impress/lib/procedure.js:78:22)
  WsChannel.rpc (/node_modules/metacom/lib/channel.js:136:27)
  processTicksAndRejections (internal/process/task_queues.js:95:5)

The second service logs:

22:07:26  W2   error   127.0.0.1        GET     /api    500     Error: interfaces is not iterable
  WebSocket.<anonymous> (/node_modules/metacom/lib/client.js:50:18)
  WebSocket.onMessage (/node_modules/ws/lib/event-target.js:199:18)
  WebSocket.emit (events.js:400:28)
  Receiver.receiverOnMessage (/node_modules/ws/lib/websocket.js:1022:20)
  Receiver.emit (events.js:400:28)
  Receiver.dataMessage (/node_modules/ws/lib/receiver.js:522:14)
  Receiver.getData (/node_modules/ws/lib/receiver.js:440:17)
  Receiver.startLoop (/node_modules/ws/lib/receiver.js:148:22)
  Receiver._write (/node_modules/ws/lib/receiver.js:83:10)
  writeOrBuffer (internal/streams/writable.js:358:12)

The browser logs:

Uncaught Error: interfaces is not iterable
    at WebsocketTransport.message (registration.js:120)
    at WebSocket.<anonymous> (registration.js:200)

Note It works fine if I just load a promo interface at the mc.js file directly and then call it.

Desktop:

  • OS: Ubuntu 20.04
  • Node.js version: 14.17.4

muturgan avatar Oct 02 '21 22:10 muturgan

Example: https://github.com/metarhia/Example/blob/6bb335724357510c99cf11c60438bc856ea0e4aa/application/static/console.js#L461

Intorspect method expect interfaceNames. It is not a bug

georgolden avatar Oct 27 '21 00:10 georgolden