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
[TIMOB-25242] Android: Improve validation in filenameExists() #9422
Conversation
Questions: does the fact that JSON.parse("index.json") does not return an object indicate a larger problem? If we're trying to load a module that should exist and was built into the app, but this filenameExists() call returns null, that could be almost as bad as the V8Exception. And wouldn't any subsequent calls to filenameExists() for any files just return null because you're missing this critical index file? |
We hit the exception in question intermittently in our app. We'll hit it, then launch the app again, and we don't hit it. Assuming that index.json is built at compile time, then it clearly exists on the device even when the exception is being thrown. So it's probably not so much an issue of the index.json not existing, but more of a race condition of sorts. I don't know if that means there should be some kind of retry mechanism when you can't parse index.json. At any rate, a casual inspection of the code would suggest that if index.json is not parseable, there's no way to require() a JS module. So that's pretty much going to kill the app. |
@@ -617,6 +617,9 @@ Module.prototype.filenameExists = function (filename) { | |||
if (!fileIndex) { | |||
var json = assets.readAsset('index.json'); | |||
fileIndex = JSON.parse(json); | |||
if (!fileIndex) { |
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.
I think we want to explicitly return a Boolean in this method. I understand that null
is "truthy" and evaluates to false
, but I'd strongly prefer we simply alter the return statement below to be:
return filename && (filename in fileIndex);
@jpriebe Yes, being unable to load index.json is indicative of a larger problem. That file is generated at build time with the listing of assets in the app. If that file is missing or corrupt, I don't believe you'd be able to require any file. |
So taking a quick look, my best guess here is that the |
@sgtcoolguy Thanks for taking a look, updated PR! |
Any update? |
This commit has seriously bugs.
Errors are related |
af9806c
to
d71e12a
Compare
FR Passed. No V8 exceptions seen & module loading works fine, checked with using Studio Ver: 4.10.0.201709271713 |
filenameExists()
from crashing whenfileIndex
isnull
JIRA Ticket