paulmillr / readdirp

Recursive version of fs.readdir with streaming api.
https://paulmillr.com
MIT License
378 stars 51 forks source link

Uncaught Error: Circular symlink detected #173

Closed aleksey-hoffman closed 3 years ago

aleksey-hoffman commented 3 years ago

I get an uncaught error when trying to walk a directory:

Occurs with and without lstat: true

Code

const readdirp = require('readdirp')
const through2 = require('through2')

let w_stream = fs.createWriteStream('C:/test/write.txt')
let r_stream = readdirp('C:/', {
  type: 'files_directories',
  lstat: true
})
let lineTransformer = through2.obj(function(data, enc, next) {
  this.push(`${data.fullPath}\n`)
  next()
})

r_stream
  .pipe(lineTransformer)
  .pipe(w_stream)

Error

events.js:292 
Uncaught Error: Circular symlink detected: 
"C:\Users\Default\AppData\Local\Application Data" 
points to 
"C:\Users\Default\AppData\Local"
    at ReaddirpStream._getEntryType (index.js?b048:217)
    at async ReaddirpStream._read (index.js?b048:128)
_getEntryType @ index.js?b048:217

image

aleksey-hoffman commented 3 years ago

I think it should just ignore circular links and continue. Right now it throws the error stops the read stream

paulmillr commented 3 years ago

update to 3.6

aleksey-hoffman commented 3 years ago

@paulmillr thank you for releasing 3.6, it works now