Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Other: fileBox.toFile raise exception 'uncaughtException Error: The stream is not readable. Maybe has already been consumed, and now it was drained. See: https://github.com/huan/file-box/issues/50' #239

Closed
timewalker08 opened this issue Aug 10, 2023 · 3 comments

Comments

@timewalker08
Copy link

Please make sure you have read the Wechaty Puppet Service from Wechaty Official Website before you continue writting this issue.

Question

I am trying to save image if wechat receive an image.

Following is my code:

async function onMessage(msg: Message) {
    if (msg.type() === bot.Message.Type.Image) {
        const fileBox = await msg.toFileBox();
        const fileName = `${fileBox.name}.png`;
        await fileBox.toFile(fileName, true);
        console.log(`Image has been downloaded as ${fileName}`);
    }
}

The code didn't read the stream, however, it raise error:

uncaughtException Error: The stream is not readable. Maybe has already been consumed, and now it was drained. See: huan/file-box#50 at FileBox.toStream (/Users/linsimin/Code/Learnings/wechaty/wechaty-test/node_modules/file-box/src/file-box.ts:796:17) at FileBox.pipe (/Users/linsimin/Code/Learnings/wechaty/wechaty-test/node_modules/file-box/src/file-box.ts:1020:10) at /Users/linsimin/Code/Learnings/wechaty/wechaty-test/node_modules/file-box/src/file-box.ts:926:12 at new Promise () at FileBox.toFile (/Users/linsimin/Code/Learnings/wechaty/wechaty-test/node_modules/file-box/src/file-box.ts:921:11) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async WechatyImpl.onMessage (/Users/linsimin/Code/Learnings/wechaty/wechaty-test/src/wechat-bot.ts:47:9)

Source code is here: https://github.com/timewalker08/wechaty-test

@yb411521921
Copy link

me too.

@su-chang
Copy link
Member

@timewalker08 See some details here: huan/file-box#50

@su-chang
Copy link
Member

暂无反馈,关闭该issue。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants