node-modules / urllib

Request HTTP(s) URLs in a complex world.
MIT License
725 stars 115 forks source link

When using version 3.x, if an error occurs in writeStream, no error will be thrown #459

Closed PeterRao closed 1 year ago

PeterRao commented 1 year ago
const fs = require('fs');
const { request } = require('urllib');
const writeStream = fs.createWriteStream(__dirname + '/not-exist/test.js').on('error', (e) => {
  console.log('folder not exist');
})

request('https://aaaaddd.oss-cn-zhangjiakou.aliyuncs.com/%E6%96%B0%E5%BB%BA%E6%96%87%E6%9C%AC%E6%96%87%E6%A1%A3.txt', {
  writeStream: writeStream
}).then(data => {
  console.log('success');
}).catch(e => {
  console.log('error', e.message);
})

use 2.33.1

folder not exist
error ENOENT: 

use 3.17.1

folder not exist
success
fengmk2 commented 1 year ago

复现的 node 版本:14、16,确认 node >= 18 不会出现此问题。