ayqy / string-to-file-stream

NodeJS create file stream from string.
http://www.ayqy.net/blog/node-js%e4%bb%8e%e5%ad%97%e7%ac%a6%e4%b8%b2%e7%94%9f%e6%88%90%e6%96%87%e4%bb%b6%e6%b5%81/
MIT License
19 stars 7 forks source link

TypeError: "size" argument must be a number 0|iconfont | at Function.Buffer.allocUnsafe (buffer.js:251:3) #2

Closed baidongying closed 3 years ago

baidongying commented 4 years ago

this.readableHighWaterMark 未定义,在测试服务器上导致报错了

ayqy commented 4 years ago

Which version of Node.js used on the test server? v10.x or later version are all supported.

https://github.com/nodejs/node/blob/master/lib/internal/fs/streams.js#L193

可能是测试服务器上node版本过低,建议使用10.x以上版本,本地v10.18.0测试没有问题

zjffun commented 3 years ago

Reproduction

test.js

const string2fileStream = require('./index.js');

string2fileStream("test");

console

$ /c/Users/zhangjufeng/Downloads/node-v8.9.0-win-x64/node-v8.9.0-win-x64/node test.js
buffer.js:224
    throw err;
    ^

TypeError: "size" argument must be a number
    at Function.Buffer.allocUnsafe (buffer.js:251:3)
    at allocNewPool (C:\Users\zhangjufeng\gh\string-to-file-stream\index.js:21:19)
    at ReadStream._read (C:\Users\zhangjufeng\gh\string-to-file-stream\index.js:118:5)
zjffun commented 3 years ago

A fix #4

ayqy commented 3 years ago

The latest version(@1.3.0) fixed this, thanks to @zjffun , it's turn to close.