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

[Bug] File descriptors aren't supported in the FS layer #359

Closed
arcanis opened this issue Aug 16, 2019 · 2 comments
Closed

[Bug] File descriptors aren't supported in the FS layer #359

arcanis opened this issue Aug 16, 2019 · 2 comments
Labels
bug Something isn't working reproducible This issue can be successfully reproduced

Comments

@arcanis
Copy link
Member

arcanis commented Aug 16, 2019

Describe the bug

Our FS layer doesn't support file descriptors at the moment, which causes issues in some cases (particularly ESLint).

To fix that, we need to:

  • Create a new type in path.ts, FSPath<T>, which is T | number
  • Use FSPath<NativePath> in the fs functions that accepts file descriptors
  • Update ProxiedFS to accept/return a FSPath<T> instead of Path
  • Update ProxiedFS to not call mapFromBase / mapToBase on fds

To Reproduce

const {openSync, readFileSync, writeFileSync} = require(`fs`);

writeFileSync(`foo`, `hello world`);
const fd = openSync(`foo`, `r`);

expect(() => readFileSync(fd)).not.toThrow();

Additional context

Ref SublimeLinter/SublimeLinter#1644

@yarnbot
Copy link
Collaborator

yarnbot commented Aug 16, 2019

This issue reproduces on master:

Error: expect(received).not.toThrow()

Error name:    "TypeError"
Error message: "p.match is not a function"

      27972 |     }
      27973 |     mapToBase(p) {
    > 27974 |         const match = p.match(this.mapToBaseRegExp);
            |                         ^
      27975 |         if (!match)
      27976 |             return p;
      27977 |         if (match[3])

      at VirtualFS.mapToBase (../../github/workspace/.pnp.js:27974:25)
      at VirtualFS.readFileSync (../../github/workspace/.pnp.js:25739:50)
      at PosixFS.readFileSync (../../github/workspace/.pnp.js:25739:32)
      at expect (evalmachine.<anonymous>:7:14)
      at Object.<anonymous> (../../github/workspace/.yarn/cache/expect-npm-24.8.0-71cbc75691.zip/node_modules/expect/build/toThrowMatchers.js:81:11)
      at Object.throwingMatcher [as toThrow] (../../github/workspace/.yarn/cache/expect-npm-24.8.0-71cbc75691.zip/node_modules/expect/build/index.js:342:33)
      at module.exports (evalmachine.<anonymous>:7:36)
      at executeInTempDirectory (../../github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.18-6d5236b6bc.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:56:19)
      at executeInTempDirectory (../../github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.18-6d5236b6bc.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:17:22)
      at Object.executeRepro (../../github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.18-6d5236b6bc.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:24:18)
    at module.exports (evalmachine.<anonymous>:7:36)
    at executeInTempDirectory (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.18-6d5236b6bc.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:56:19)
    at executeInTempDirectory (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.18-6d5236b6bc.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:17:22)
    at Object.executeRepro (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.18-6d5236b6bc.zip/node_modules/@arcanis/sherlock/lib/executeRepro.js:24:18)
    at ExecCommand.execute (/github/workspace/.yarn/cache/@arcanis-sherlock-npm-1.0.18-6d5236b6bc.zip/node_modules/@arcanis/sherlock/lib/commands/exec.js:25:59)

@yarnbot yarnbot added the reproducible This issue can be successfully reproduced label Aug 16, 2019
@arcanis
Copy link
Member Author

arcanis commented Aug 20, 2019

Fixed with #363

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working reproducible This issue can be successfully reproduced
Projects
None yet
Development

No branches or pull requests

2 participants