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

TypeError: Cannot read property 'Symbol(type)' of undefined, from fs module isFile #37154

Closed
Powersource opened this issue Jan 31, 2021 · 3 comments

Comments

@Powersource
Copy link

  • Platform: Linux lap 5.10.11-arch1-1 #1 SMP PREEMPT Wed, 27 Jan 2021 13:53:16 +0000 x86_64 GNU/Linux

Reproduced the bug on electron 10.3.1 and 11.2.1, with node 12.16.3 and 12.18.3 respectively

I'm running node 10.13.0 on my system using nvm but I don't think that affects the code running inside electron?

What steps will reproduce the bug?

The running of isFile() (from require('fs').promises) on this line. That project is not the simplest to build so I'm not expecting you to do that but some pointers for where I could look when debugging would be helpful. Will maybe produce a simpler reproduction in my debugging.

How often does it reproduce? Is there a required condition?

Every time

What is the expected behavior?

Not printing this error

What do you see instead?

In the electron console

main.js:12 TypeError: Cannot read property 'Symbol(type)' of undefined
    at isFile (internal/fs/utils.js:104)
    at main.js:60
    at Array.filter (<anonymous>)
    at e.f (main.js:60)
    at u (main.js:1)
    at e._n (main.js:1)
    at e._n (main.js:1)
    at main.js:1

when clicking into internal/fs/utils.js:104

[...]
class Dirent {
  constructor(name, type) {
    this.name = name;
    this[kType] = type;
  }

  isDirectory() {
    return this[kType] === UV_DIRENT_DIR;
  }

  isFile() {
// V-- line 104
    return this[kType] === UV_DIRENT_FILE;
  }

  isBlockDevice() {
    return this[kType] === UV_DIRENT_BLOCK;
  }

  isCharacterDevice() {
    return this[kType] === UV_DIRENT_CHAR;
  }

  isSymbolicLink() {
    return this[kType] === UV_DIRENT_LINK;
  }

  isFIFO() {
    return this[kType] === UV_DIRENT_FIFO;
  }

  isSocket() {
    return this[kType] === UV_DIRENT_SOCKET;
  }
}
[...]

This issue looks a bit similar but not the same #24546 since they were having problems with http2, something I don't believe I'm using.

@Powersource
Copy link
Author

And to help you decipher the code a bit, this dirent is essentially produced by calling

fs.readdir('./translations', {withFileTypes: true});

@cjihrig
Copy link
Contributor

cjihrig commented Jan 31, 2021

Here is the line reported in the stack trace. It looks like in your code you are losing the this. If you remove the destructuring it should work.

@Powersource
Copy link
Author

Yes thank you so much, that seems to have fixed it!!! ❤️ ❤️ ❤️

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

2 participants