-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
fix(compiler-cli): handle pseudo cycles in inline source-maps #40435
fix(compiler-cli): handle pseudo cycles in inline source-maps #40435
Conversation
d68569a
to
b6af801
Compare
c0a2aeb
to
02ad8f0
Compare
9ddfdee
to
806ad70
Compare
b62779d
to
a79bfe1
Compare
packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file_loader.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file_loader.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file_loader.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file_loader.ts
Outdated
Show resolved
Hide resolved
// The source file was provided inline and its contents did not include an inline source-map. | ||
// So we don't try to load an external source-map from the file-system, since this can lead to | ||
// invalid circular dependencies. |
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.
Could there be legitimate cases that will now hit this case and fail to load? i.e. a source map that references another source file inline, which has an external source map comment to a source map file that actually exists? If I understand correctly, that scenario will be rejected now where the external source map file is refused to load.
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 thought about this. And of course it is feasible that this might happen. But I believe that in practice it will not: our library builds will not do this. Further, I think that there is just as good a chance that trying to load something from the disk from something that was inline is just as likely to produce a failure of some kind.
The bottom line is that anything is possible, I don't think it is possible to handle everything and most of these corner cases will be wrong in some way or another anyway whatever we do!
When a source-map has an inline source, any source-map linked from that source should only be loaded if itself is also inline; it should not attempt to load a source-map from the file-system. Otherwise we can find ourselves with inadvertent infinite cyclic dependencies. For example, if a transpiler takes a file (e.g. index.js) and generates a new file overwriting the original file - capturing the original source inline in the new source-map (index.js.map) - the source file loader might read the inline original file (also index.js) and then try to load the `index.js.map` file from disk - ad infinitum. Note that the first call to `loadSourceFile()` is special, since you can pass in the source-file and source-map contents directly as in-memory strrngs. This is common if the transpiler has just generated these and has not yet written them to disk. When the contents are passed into `loadSourceFile()` directly, they are not treated as "inline" for the purposes described above since there is no chance of these "in-memory" source and source-map contents being caught up in a cyclic dependency. Fixes angular#40408
fa4d239
to
965c0e7
Compare
When a source-map has an inline source, any source-map linked from that source should only be loaded if itself is also inline; it should not attempt to load a source-map from the file-system. Otherwise we can find ourselves with inadvertent infinite cyclic dependencies. For example, if a transpiler takes a file (e.g. index.js) and generates a new file overwriting the original file - capturing the original source inline in the new source-map (index.js.map) - the source file loader might read the inline original file (also index.js) and then try to load the `index.js.map` file from disk - ad infinitum. Note that the first call to `loadSourceFile()` is special, since you can pass in the source-file and source-map contents directly as in-memory strrngs. This is common if the transpiler has just generated these and has not yet written them to disk. When the contents are passed into `loadSourceFile()` directly, they are not treated as "inline" for the purposes described above since there is no chance of these "in-memory" source and source-map contents being caught up in a cyclic dependency. Fixes #40408 PR Close #40435
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
When a source-map has an inline source, any source-map linked from
that source should only be loaded if itself is also inline; it should not
attempt to load a source-map from the file-system. Otherwise we can
find ourselves with inadvertent infinite cyclic dependencies.
For example if a transpiler takes a file (e.g. index.js) and generates
a new file overwriting the original file (but capturing the original
source inline in the new source-map (index.js.map) the source
file loader might read the inline original file (also index.js) and
then try to load the
index.js.map
file from disk - ad infinitum.Fixes #40408