-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Don't fail the test suite when convert-source-map throws an error #9058
Don't fail the test suite when convert-source-map throws an error #9058
Conversation
Hi AlexLandau! Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
transformed.map = inlineSourceMap.toJSON(); | ||
} | ||
} catch (e) { | ||
// Error processing the source map; proceed as if it doesn't exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should at least warn in this case, no? likely a bug in a transformer. Will also mess up breakpoints and code coverage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I've added a warning via console.warn (not sure if that's the preferred method, or if we should add chalking, etc.).
} catch (e) { | ||
console.warn( | ||
`jest-transform: The source map produced for the file ${filename} ` + | ||
'was invalid. Proceeding without source mapping for that file.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Information on what transformer is responsible may also be helpful here (for the case in which the transformer is consistently failing), but the closest I can find is the transform path, which may look a bit wonky. Is that worth adding, or should we leave the user to infer the transformer from which file is affected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using _getTransformPath
seems reasonable. You can make the path to it relative from config.rootDir
, and it shouldn't be too bad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On further examination, the transform path is used by require
and is thus probably a package name or relative path, so I'm including it as-is.
Codecov Report
@@ Coverage Diff @@
## master #9058 +/- ##
==========================================
+ Coverage 64.07% 64.07% +<.01%
==========================================
Files 277 277
Lines 11679 11681 +2
Branches 2863 2863
==========================================
+ Hits 7483 7485 +2
Misses 3572 3572
Partials 624 624
Continue to review full report at Codecov.
|
@SimenB how do we get this merged? |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Fixes #8966.
Summary
This prevents rare, non-deterministic errors of the following type (further described in #8966):
The change treats cases in which the
convertSourceMap.fromSource
operation throws an exception as the same as if it had returned a falsy value; the code already handles the latter case.Test plan
This includes a unit test for ScriptTransformer. The test fails with
SyntaxError: Unexpected end of JSON input
when run without the new try-catch block; with the new change, the test passes.