Skip to content

Commit

Permalink
Prevent unhandled rejection with buildCodeFrameMessage (#567)
Browse files Browse the repository at this point in the history
Summary:
We encounter regular resolution issue but was not captured by throwing
proper resolution error, this handles the specific case we're seeing.

```
(node:309) UnhandledPromiseRejectionWarning: Error: EISDIR: illegal operation on a directory, read
    at Object.readSync (fs.js:498:3)
    at tryReadSync (fs.js:332:20)
    at Object.readFileSync (fs.js:369:19)
    at UnableToResolveError.buildCodeFrameMessage
```

Ever since upgraded, we've seen the above error messages representing in fact an actual resolution error that should have been represented by `Unable to resolve module %s from %s: %s` messages.

**Test plan**
- CI

Pull Request resolved: #567

Reviewed By: MichaReiser

Differential Revision: D24883722

Pulled By: cpojer

fbshipit-source-id: 47c6dc4445f6a6656848743c9f1987e7f3701d78
  • Loading branch information
raejin authored and facebook-github-bot committed Nov 13, 2020
1 parent 279f04f commit 1e6cec8
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class UnableToResolveError extends Error {
try {
file = fs.readFileSync(this.originModulePath, 'utf8');
} catch (error) {
if (error.code === 'ENOENT') {
if (error.code === 'ENOENT' || error.code === 'EISDIR') {
// We're probably dealing with a virtualised file system where
// `this.originModulePath` doesn't actually exist on disk.
// We can't show a code frame, but there's no need to let this I/O
Expand Down

0 comments on commit 1e6cec8

Please sign in to comment.