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(ngcc): bad package resilience #36083
fix(ngcc): bad package resilience #36083
Conversation
petebacondarwin
commented
Mar 16, 2020
•
edited
edited
08ff318
to
fb73362
Compare
fb73362
to
5abfd11
Compare
I need to run a check against the CLI branch on ngcc-validation too. |
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 generally like this (with minor comments/suggestions) 👍
Also, great job spliting it up into cleanly separated commits 💯
Just a couple of thoughts/concerns:
-
I think I would prefer to have a consistent default value for
errorOnFailedEntryPoint
(false), regardless of how ngcc is called. I feel like it complicates things for little benefit otherwise. Especially given that changing the default based on programmatic call or not is orthogonal to the knowledge one has for the entry-points.
If anything, it might make sense to change the default value depending on whether thetarget
option is set, but that would complicate things even more. (Even so, I would probably prefer this over the current behavior.)
I can be definitely convinced otherwise, though. What are your thoughts? -
Previously, ngcc operated under the assumption that the found format properties would either be successfully compiled or the operation would halt altogether. This gave us the freedom to arbitrarily associate DTS processing with the first found format property. Now, this assumption is no longer true: It is theoretically possible that processing of
es2015
for entry-pointfoo/bar
(which hasprocessDts: true
) fails, but processingmodule
for the same entry-point (withprocessDts: false
) succeeds.
Should we rethink how we associate DTS processing with specific entry-point formats? (Note that this might complicate things significantly for parallel mode.)
Given the above and the fact that there is avery low probability for it to cause problems, I tend to believe it is better to keep operating under the current assumptions. We could also cancel/skip processing of all formats of an entry-point as soon as the task withprocessDts: true
for that entry-point fails, but the extra compication is probably not worth it.
packages/compiler-cli/ngcc/src/execution/task_selection/parallel_task_queue.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/ngcc/src/execution/task_selection/parallel_task_queue.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/ngcc/test/execution/task_selection/parallel_task_queue_spec.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/ngcc/src/execution/task_selection/base_task_queue.ts
Outdated
Show resolved
Hide resolved
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.
Excellent work!
I do agree with @gkalpak on the choice of the default value of the option, I'd prefer it to be always the same independent of the usage, or indeed be derived from targetedEntryPoint
.
packages/compiler-cli/ngcc/src/execution/task_selection/base_task_queue.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/ngcc/test/execution/task_selection/serial_task_queue_spec.ts
Outdated
Show resolved
Hide resolved
fd991ae
to
902eb1e
Compare
902eb1e
to
2d4b6b3
Compare
Regarding the defaults. I have made both programmatic and command line version of This will mean that the CLI will need to add this option to the async CLI integration point to benefit from this. I was not happy to make the default Furthermore, I don't believe that we should tie this |
2d4b6b3
to
ea416e9
Compare
Of course now the problem will be that the CLI needs to provide a command line option but it will fail if there is a version mismatch and the option is not yet available on the versions of Angular compiler-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.
Some minor comments. Otherwise lgtm 👍
packages/compiler-cli/ngcc/test/execution/single_processor_executor_spec.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/ngcc/src/execution/tasks/queues/parallel_task_queue.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/ngcc/src/execution/tasks/queues/base_task_queue.ts
Outdated
Show resolved
Hide resolved
packages/compiler-cli/ngcc/src/writing/new_entry_point_file_writer.ts
Outdated
Show resolved
Hide resolved
BTW, the 4th commit message needs updating wrt the current defaults for |
ea416e9
to
4939c26
Compare
This sets up the task execution to be able to report failed compiles
Moving the definition of the `onTaskCompleted` callback into `mainNgcc()` allows it to be configured based on options passed in there more easily. This will be the case when we want to configure whether to log or throw an error for tasks that failed to be processed successfully. This commit also creates two new folders and moves the code around a bit to make it easier to navigate the code§: * `execution/tasks`: specific helpers such as task completion handlers * `execution/tasks/queues`: the `TaskQueue` implementations and helpers
Later when we implement the ability to continue processing when tasks have failed to compile, we will also need to avoid processing tasks that depend upon the failed task. This refactoring exposes this list of dependent tasks in a way that can be used to skip processing of tasks that depend upon a failed task. It also changes the blocking model of the parallel mode of operation so that non-typings tasks are now blocked on their corresponding typings task. Previously the non-typings tasks could be triggered to run in parallel to the typings task, since they do not have a hard dependency on each other, but this made it difficult to skip task correctly if the typings task failed, since it was possible that a non-typings task was already in flight when the typings task failed. The result of this is a small potential degradation of performance in async parallel processing mode, in the rare cases that there were not enough unblocked tasks to make use of all the available workers.
bf0f800
to
408714f
Compare
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.
LGTM 🎉 👌 💯
Commit message typo:
-This change adds a new `errorOnFailedEntryPoint` option to `mainNgcc` specifies whether ngcc should ...
+This change adds a new `errorOnFailedEntryPoint` option to `mainNgcc` that specifies whether ngcc should ...
Previously, when an entry-point contained code that caused its compilation to fail, ngcc would exit in the middle of processing, possibly leaving other entry-points in a corrupt state. This change adds a new `errorOnFailedEntryPoint` option to `mainNgcc` that specifies whether ngcc should exit immediately or log an error and continue processing other entry-points. The default is `false` so that ngcc will not error but continue processing as much as possible. This is useful in post-install hooks, and async CLI integration, where we do not have as much control over which entry-points should be processed. The option is forced to true if the `targetEntryPointPath` is provided, such as the sync integration with the CLI, since in that case it is targeting an entry-point that will actually be used in the current project so we do want ngcc to exit with an error at that point.
When two entry-points overlap, ngcc may attempt to process some files twice. Previously, when this occured ngcc would just exit with an error preventing any other entry-points from being processed. This commit changes ngcc so that if `errorOnFailedEntryPoint` is false, it will simply log an error and continue to process entry-points. This is useful when ngcc is processing the entire node_modules folder and there are some invalid entry-points that the project doesn't actually use.
408714f
to
4106aca
Compare
Moving the definition of the `onTaskCompleted` callback into `mainNgcc()` allows it to be configured based on options passed in there more easily. This will be the case when we want to configure whether to log or throw an error for tasks that failed to be processed successfully. This commit also creates two new folders and moves the code around a bit to make it easier to navigate the code§: * `execution/tasks`: specific helpers such as task completion handlers * `execution/tasks/queues`: the `TaskQueue` implementations and helpers PR Close #36083
…36083) Later when we implement the ability to continue processing when tasks have failed to compile, we will also need to avoid processing tasks that depend upon the failed task. This refactoring exposes this list of dependent tasks in a way that can be used to skip processing of tasks that depend upon a failed task. It also changes the blocking model of the parallel mode of operation so that non-typings tasks are now blocked on their corresponding typings task. Previously the non-typings tasks could be triggered to run in parallel to the typings task, since they do not have a hard dependency on each other, but this made it difficult to skip task correctly if the typings task failed, since it was possible that a non-typings task was already in flight when the typings task failed. The result of this is a small potential degradation of performance in async parallel processing mode, in the rare cases that there were not enough unblocked tasks to make use of all the available workers. PR Close #36083
Previously, when an entry-point contained code that caused its compilation to fail, ngcc would exit in the middle of processing, possibly leaving other entry-points in a corrupt state. This change adds a new `errorOnFailedEntryPoint` option to `mainNgcc` that specifies whether ngcc should exit immediately or log an error and continue processing other entry-points. The default is `false` so that ngcc will not error but continue processing as much as possible. This is useful in post-install hooks, and async CLI integration, where we do not have as much control over which entry-points should be processed. The option is forced to true if the `targetEntryPointPath` is provided, such as the sync integration with the CLI, since in that case it is targeting an entry-point that will actually be used in the current project so we do want ngcc to exit with an error at that point. PR Close #36083
When two entry-points overlap, ngcc may attempt to process some files twice. Previously, when this occured ngcc would just exit with an error preventing any other entry-points from being processed. This commit changes ngcc so that if `errorOnFailedEntryPoint` is false, it will simply log an error and continue to process entry-points. This is useful when ngcc is processing the entire node_modules folder and there are some invalid entry-points that the project doesn't actually use. PR Close #36083
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. |