Skip to content
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

Attribute in deps stopped working with Ivy #36479

Closed
waterplea opened this issue Apr 7, 2020 · 2 comments
Closed

Attribute in deps stopped working with Ivy #36479

waterplea opened this issue Apr 7, 2020 · 2 comments
Assignees
Labels
area: core Issues related to the framework runtime core: di freq1: low P2 The issue is important to a large percentage of users, with a workaround regression Indicates than the issue relates to something that worked in a previous version state: has PR type: bug/fix
Milestone

Comments

@waterplea
Copy link
Contributor

🐞 bug report

Affected Package

The issue is caused by package @angular/core

Is this a regression?

Yes, the previous version in which this bug was not present was: 8

Description

You can use Attribute decorator in deps for providers like this:

{
    provide: TOKEN,
    deps: [[new Attribute('token')]],
    useFactory: factory,
}

It stopped working with Ivy and Angular 9

🔬 Minimal Reproduction

Working Angular 8:
https://stackblitz.com/edit/angular-attribute-deps

Broken Angular 9:
https://ng-run.com/edit/hyppU3cXJCaRYLYVDAQp

🔥 Exception or Error


R3InjectorError(AppModule)[[object Object] -> [object Object] -> [object Object]]: 
  NullInjectorError: No provider for [object Object]!

🌍 Your Environment

Angular Version:

9.1.0
@AndrewKushnir AndrewKushnir added area: core Issues related to the framework runtime core: di labels Apr 7, 2020
@ngbot ngbot bot modified the milestone: needsTriage Apr 7, 2020
@kara kara added type: bug/fix regression Indicates than the issue relates to something that worked in a previous version freq1: low labels Apr 7, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Apr 7, 2020
@sonukapoor
Copy link
Contributor

@AndrewKushnir i can take a look at this.

sonukapoor added a commit to sonukapoor/angular that referenced this issue Apr 21, 2020
sonukapoor added a commit to sonukapoor/angular that referenced this issue Apr 21, 2020
sonukapoor added a commit to sonukapoor/angular that referenced this issue Apr 21, 2020
sonukapoor added a commit to sonukapoor/angular that referenced this issue Apr 21, 2020
sonukapoor added a commit to sonukapoor/angular that referenced this issue Apr 22, 2020
Injecting a new `Attribute` through `deps` is currently not working
in `ivy`. To fix this, the `injectArgs` function needs to
be moved into a common place, that does not cause any circular
dependencies.

PR Closes angular#36479
sonukapoor added a commit to sonukapoor/angular that referenced this issue Apr 22, 2020
Injecting a new `Attribute` through `deps` is currently not working
in `ivy`. To fix this, the `injectArgs` function needs to
be moved into a common place, that does not cause any circular
dependencies.

PR Closes angular#36479
sonukapoor added a commit to sonukapoor/angular that referenced this issue Apr 24, 2020
Injecting a new `Attribute` through `deps` is currently not working
in `ivy`. To fix this, the `injectArgs` function needs to
be moved into a common place, that does not cause any circular
dependencies.

PR Closes angular#36479
sonukapoor added a commit to sonukapoor/angular that referenced this issue Apr 24, 2020
Injecting a new `Attribute` through `deps` is currently not working
in `ivy`. To fix this, the `injectArgs` function needs to
be moved into a common place, that does not cause any circular
dependencies.

PR Closes angular#36479
sonukapoor added a commit to sonukapoor/angular that referenced this issue Apr 24, 2020
This commit fixes a bug when injecting `Attribute`'s using `deps` in
`ivy`. This was caused by the missing condition in the `injectArgs` function.

This commit specifically also takes care of the following:

  - Removes existing circular dependencies caused by importing the tokens
  `InjectFlags`, `InjectionToken`, `resolveForwardRef` from the `di` instructions.
  - Updates `bundle.golden_symbols.json` with the tokens.
  - Updates payload limits for `main-es2015` from 137320 to 138095, which is caused
  by `Attribute` decorator.

PR Closes angular#36479
sonukapoor added a commit to sonukapoor/angular that referenced this issue Apr 28, 2020
This commit moves the `injectArgs` function that is used in multiple
places into `util.ts` file. It should help avoid circular dependency
issues when the function is updated or used in other places.

PR Closes angular#36479
sonukapoor added a commit to sonukapoor/angular that referenced this issue Apr 28, 2020
This commit fixes a bug when `Attribute` DI decorator is used in the
`deps` section of a token that uses a factory function. The problem
appeared because the `Attribute` DI decorator was not handled correctly
while injecting factory function attributes.

Note: the fix required referencing the `injectAttribute` function (to
properly inject attribute value), so that triggered payload size limits
update.

PR Closes angular#36479
sonukapoor added a commit to sonukapoor/angular that referenced this issue May 7, 2020
This commit moves the `injectArgs` function that is used in multiple
places into `util.ts` file. It should help avoid circular dependency
issues when the function is updated or used in other places.

PR Closes angular#36479
sonukapoor added a commit to sonukapoor/angular that referenced this issue May 7, 2020
This commit fixes a bug when `Attribute` DI decorator is used in the
`deps` section of a token that uses a factory function. The problem
appeared because the `Attribute` DI decorator was not handled correctly
while injecting factory function attributes.

Note: the fix required referencing the `injectAttribute` function (to
properly inject attribute value), so that triggered payload size limits
update.

PR Closes angular#36479
sonukapoor added a commit to sonukapoor/angular that referenced this issue Sep 9, 2020
This commit fixes a bug when `Attribute` DI decorator is used in the
`deps` section of a token that uses a factory function. The problem
appeared because the `Attribute` DI decorator was not handled correctly
while injecting factory function attributes.

Note: the fix required referencing the `injectAttribute` function (to
properly inject attribute value), so that triggered payload size limits
update.

Closes angular#36479
sonukapoor added a commit to sonukapoor/angular that referenced this issue Sep 9, 2020
This commit fixes a bug when `Attribute` DI decorator is used in the
`deps` section of a token that uses a factory function. The problem
appeared because the `Attribute` DI decorator was not handled correctly
while injecting factory function attributes.

Closes angular#36479
sonukapoor added a commit to sonukapoor/angular that referenced this issue Sep 11, 2020
This commit fixes a bug when `Attribute` DI decorator is used in the
`deps` section of a token that uses a factory function. The problem
appeared because the `Attribute` DI decorator was not handled correctly
while injecting factory function attributes.

Closes angular#36479
sonukapoor added a commit to sonukapoor/angular that referenced this issue Sep 19, 2020
This commit fixes a bug when `Attribute` DI decorator is used in the
`deps` section of a token that uses a factory function. The problem
appeared because the `Attribute` DI decorator was not handled correctly
while injecting factory function attributes.

Closes angular#36479
@jelbourn jelbourn added the P2 The issue is important to a large percentage of users, with a workaround label Oct 1, 2020
sonukapoor added a commit to sonukapoor/angular that referenced this issue Oct 2, 2020
This commit fixes a bug when `Attribute` DI decorator is used in the
`deps` section of a token that uses a factory function. The problem
appeared because the `Attribute` DI decorator was not handled correctly
while injecting factory function attributes.

Closes angular#36479
mhevery pushed a commit to sonukapoor/angular that referenced this issue Nov 18, 2020
This commit fixes a bug when `Attribute` DI decorator is used in the
`deps` section of a token that uses a factory function. The problem
appeared because the `Attribute` DI decorator was not handled correctly
while injecting factory function attributes.

Closes angular#36479
AndrewKushnir pushed a commit that referenced this issue Nov 19, 2020
…ken (#37085)

This commit fixes a bug when `Attribute` DI decorator is used in the
`deps` section of a token that uses a factory function. The problem
appeared because the `Attribute` DI decorator was not handled correctly
while injecting factory function attributes.

Closes #36479

PR Close #37085
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime core: di freq1: low P2 The issue is important to a large percentage of users, with a workaround regression Indicates than the issue relates to something that worked in a previous version state: has PR type: bug/fix
Projects
None yet
6 participants