Skip to content

Fix crash on missing libraries.json #1472

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

Merged

Conversation

annagrin
Copy link
Contributor

Emit a warning instead of crashing on missing libraries spec (libraries.json), add tests.

Copy link
Contributor

@nshahan nshahan left a comment

Choose a reason for hiding this comment

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

LGTM, with a few questions.

Now what happens after the warning message is logged? Does the program exit? Can it actually continue without the libraries.json file?

What is the libraries.json file used for? My only familiarity with it is that it will be used by the CFE when compiling the SDK. Since we precompile the SDK .dill files and vend them with the SDK I wouldn't expect a need to read this file.

@annagrin
Copy link
Contributor Author

annagrin commented Jan 7, 2022

Now what happens after the warning message is logged? Does the program exit? Can it actually continue without the libraries.json file?

dwds continues to work but does not support lookupResolvedPackageUris and lookupPackageUris VM API (returns empty results). Those are currently only used in dart-code, and are new, so we are not breaking anything by not being able to find the file. Currently many tools that use dwds do not have access to libraries.json, so this fix defaults to existing behavior in those cases instead of introducing a new crash. The next steps would be to provide libraries.json in all uses of dwds.

I'll add that information to the warning reported.

What is the libraries.json file used for? My only familiarity with it is that it will be used by the CFE when compiling the SDK. Since we precompile the SDK .dill files and vend them with the SDK I wouldn't expect a need to read this file.

It is used to resolve uris - see implementations of lookupResolvedPackageUris and lookupPackageUris in chrome_proxy_service.dart:

Future<UriList> lookupResolvedPackageUris(

and its underlying implementation in dart_uri.dart:
var libSpec = _librariesSpec?.libraryInfoFor(uri.path);

@annagrin
Copy link
Contributor Author

annagrin commented Jan 7, 2022

From offline conversation - we need to revisit usage of libraries.json in dwds. Can dwds resolve dart: uris in a different way? Examples: add an API to the incremental ddc compiler, save in sdk metadata?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants