-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(cdk/schematics): errors when attempting to read some files #19783
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
jelbourn
merged 1 commit into
angular:master
from
crisbeto:19779/cdk-schematics-null-pointer-errors
Jun 30, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"lib": ["es2015"], | ||
"types": ["node", "glob"] | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The change in general is good (enabling strict), but I wonder how this issue surfaces? Do we understand how this can happen? We asserted that a file exists in the virtual tree, and then read from it? Reading the file from the tree should not be
null
, or is this an edge case when a file is not readable somehow?https://cs.opensource.google/angular/angular-cli/+/master:packages/angular_devkit/schematics/src/tree/host-tree.ts;l=282-291?q=read&ss=angular%2Fangular-cli
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.
The assertion here was fine, but I think it failed on the one below where we didn't have an assertion.
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.
Unless I miss something, we had a check before we invoked
resolveExternalStylesheet
. And the other one just accepted a glob of source files which are guaranteed to exist in FS.Maybe the glob returned source files which exist on FS but are not available in the virtual file system. That would seem most likely. It would be good understanding this as it could potentially be a bug in the devkit, or general reasoning required for future schematic work.
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 guess it depends on whether the
resolve
call here corresponds to apath.resolve
from Node which won't check the file system, or whether it's something different that actually does the lookup. If it's the latter, your explanation sounds plausible. Either way, I think that we should get this in for the next release so people that are updating to v10 don't run into it.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.
The
resolve
call should not be relevant here. The list ofadditionalStylesheetPaths
is based on a real file system query, andresolve
just turns the absolute FS path into a virtual FS workspace relative path.So there are two options: Either the files are somehow not readable and are not added to the virtual FS tree, or our path resolution logic is flawed. And this is the point/issue I think we should figure out. Fixing the issue is great, but understanding the root cause seems beneficial. To be clear: From the beginning on I agreed that this is a good change to land either way, but it would be still worth figuring this out I assume. I'll ask the issue reporter for more information.
Also I think since this has been reported only once and seems very edgy/surprising, this is probably not P2 worthy.