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

Catch exceptions in Transformer construction #351

Closed
wants to merge 2 commits into from

Conversation

sundbry
Copy link
Contributor

@sundbry sundbry commented Jan 31, 2019

Summary

When transformerPath is set in metro.config.js, if there is a failure in loading the custom transformer, the exception is silently swallowed and all the user sees is this misleading error message (see below). In this patch, we add a catch to the promise to report the original exception to the user.

Test plan

Set an invalid transformerPath in metro.config.js to reproduce:

module.exports = {
  transformerPath: require.resolve('./fail.js'),
}
Cannot read property 'transformFile' of undefined

TypeError: Cannot read property 'transformFile' of undefined
    at /Users/go/Library/Application Support/Go Agent/pipelines/ngf-app-ios/node_modules/react-native/node_modules/metro/src/Bundler.js:83:34
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/go/Library/Application Support/Go Agent/pipelines/ngf-app-ios/node_modules/react-native/node_modules/metro/src/Bundler.js:14:24)
    at _next (/Users/go/Library/Application Support/Go Agent/pipelines/ngf-app-ios/node_modules/react-native/node_modules/metro/src/Bundler.js:34:9)

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 31, 2019
@codecov-io
Copy link

Codecov Report

Merging #351 into master will increase coverage by <.01%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #351      +/-   ##
==========================================
+ Coverage   85.01%   85.02%   +<.01%     
==========================================
  Files         171      172       +1     
  Lines        5205     5221      +16     
  Branches      793      795       +2     
==========================================
+ Hits         4425     4439      +14     
- Misses        693      695       +2     
  Partials       87       87
Impacted Files Coverage Δ
packages/metro/src/Bundler.js 92.3% <66.66%> (-7.7%) ⬇️
...ackages/buck-worker-tool/src/CommandFailedError.js 50% <0%> (ø)
packages/buck-worker-tool/src/worker-tool.js 95.18% <0%> (+0.89%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 98d16d4...45aa75b. Read the comment docs.

Copy link
Contributor

@rafeca rafeca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafeca is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants