Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Pumpify在节点8和节点10中的行为不同_Javascript_Node.js_Node Streams - Fatal编程技术网

Javascript Pumpify在节点8和节点10中的行为不同

Javascript Pumpify在节点8和节点10中的行为不同,javascript,node.js,node-streams,Javascript,Node.js,Node Streams,由于某些原因,当节点8中的流上发出错误时,错误会正确传播,然后是结束事件,但在节点10上,错误的发生顺序相反。(使用pumpify的最新2.0.1版本) 例如: “严格使用”; 常量{PassThrough,writeable}=require('stream'); const pumpify=require('pumpify'); const stream1=新的直通(); const stream2=新的可写(); const combled=pumpify(流1、流2); 组合.on('e

由于某些原因,当节点8中的流上发出错误时,错误会正确传播,然后是结束事件,但在节点10上,错误的发生顺序相反。(使用pumpify的最新2.0.1版本)

例如:

“严格使用”;
常量{PassThrough,writeable}=require('stream');
const pumpify=require('pumpify');
const stream1=新的直通();
const stream2=新的可写();
const combled=pumpify(流1、流2);
组合.on('end',()=>{
console.log('streamend');
});
组合.on('error',e=>{
log('流错误:',e);
});
stream1.emit('error','aaa');
请注意事件的相反顺序


这是预期的行为吗?我做错什么了吗?

仍然不能完全确定到底发生了什么,以防万一这会帮助到别人。问题似乎在于
PassThrough
为空。如果我将其替换为
tarfs
,并在流的顶部添加条目,它似乎可以按预期工作

“严格使用”;
const{writeable}=require('stream');
const{pack}=require('tar-fs');
const pumpify=require('pumpify');
常数stream1=pack();
const stream2=新的可写();
const combled=pumpify(流1、流2);
组合.on('end',()=>{
console.log('streamend');
});
组合.on('error',e=>{
log('流错误:',e);
});
stream1.entry({name:'file1'},'artbitrary file1 contents');
stream1.emit('error','aaa');
nvm use 8
Now using node v8.17.0 (npm v6.13.4)

node tmp.js
Stream error:  aaa
Stream end
nvm use 10
Now using node v10.19.0 (npm v6.13.4)

node tmp.js
Stream end
Stream error:  aaa
nvm use 8
Now using node v8.17.0 (npm v6.13.4)

node tmp.js
Stream error:  aaa
Stream end
nvm use 10
Now using node v10.19.0 (npm v6.13.4)

node tmp.js
Stream error:  aaa
Stream end