metarhia / metacom

RPC communication protocol for Metarhia stack 🔌
https://metarhia.com
MIT License
80 stars 40 forks source link

Stream does not end #494

Closed mysilkworld closed 7 months ago

mysilkworld commented 8 months ago

Describe the bug

During file transfer, the stream never ends due to an error in the library.

Arguments are passed incorrectly to the constructor on line 299

Passed:

const stream = new MetaReadable({ id, name, size });

Expected:

class MetaReadable extends EventEmitter {
  constructor(id, name, size, options = {})

To Reproduce

({
  access: 'public',

  method: async ({ streamId }) => {
    const readable = context.client.getStream(streamId);

    const getChunks = async () => {
      console.log('start');
      const chunks = [];
      for await (const chunk of readable) {
        chunks.push(chunk);
      }
      console.log('end');
    };

    getChunks();

    return { result: 'Stream initialized' };
  },
});

Expected behavior

The stream should end.

Screenshots

No response

Desktop (please complete the following information):

Additional context

No response

tshemsedinov commented 7 months ago

Fixed: https://github.com/metarhia/metacom/pull/497

tshemsedinov commented 7 months ago

Please try to use streams