GithubHelp home page GithubHelp logo

Comments (20)

StiliyanKushev avatar StiliyanKushev commented on April 28, 2024 1

That's the correct video you're referencing, but it's the wrong timestamp.
I can provide the screenshots in a sec.

from nest.

StiliyanKushev avatar StiliyanKushev commented on April 28, 2024 1

Okay, I'll make a repo in a minute. I can also test with different nest versions and will report up until what version it works as expected.

from nest.

StiliyanKushev avatar StiliyanKushev commented on April 28, 2024 1

Yeah, already searched in the releases, wasn't mentioned. (Another reason I suspect this to be a bug).

from nest.

StiliyanKushev avatar StiliyanKushev commented on April 28, 2024 1

Here you go, hope that's enough :)

from nest.

StiliyanKushev avatar StiliyanKushev commented on April 28, 2024 1

Notice that it works as expected if I downgrade to version 9 for example.

image

from nest.

StiliyanKushev avatar StiliyanKushev commented on April 28, 2024 1

Actually, seems to be a semi-recent bug in the latest version of @nestjs/[email protected].

image

EDIT: yeah

from nest.

H4ad avatar H4ad commented on April 28, 2024 1

@micalevisk Yeah, this is a bug introduced by my PR, alwaysTransient works because of: https://github.com/nestjs/nest/pull/12753/files#diff-22f1ab07f43abbd45f270de55b6cd35da90c02fe92cee99f67d51a37b85002c8R209-R220 which makes the module unique.

That piece of code worked before because we used those objects to differentiate each module, if he use the async version, then it will have the same issue.

We can basically revert the change for that module only, the easiest/quickest fix, the other changes we don't need to revert.

We can also go back to the conversation started at #12898, this issue could be fixed using that feature.

from nest.

kamilmysliwiec avatar kamilmysliwiec commented on April 28, 2024 1

#13083

from nest.

micalevisk avatar micalevisk commented on April 28, 2024

isn't this pretty much what the docs of alwaysTransient says here:

/**
* Indicates whether module should always be "transient", meaning,
* every time you call the static method to construct a dynamic module,
* regardless of what arguments you pass in, a new "unique" module will be created.
*
* @default false
*/
alwaysTransient?: boolean;

from nest.

StiliyanKushev avatar StiliyanKushev commented on April 28, 2024

Well, here's the thing though, the expected behavior I described is not really documented, but is clearly mentioned in one of the official nestjs courses. What I'm saying is that, alwaysTransient set to true actually works as expected, but when set to false (by default), it supposedly (as shown in the course) should still act as if alwaysTransient is set to true for providers that are the same but have different options passed (such as in my example), due to their "internal hash" being different.

from nest.

StiliyanKushev avatar StiliyanKushev commented on April 28, 2024

The version used in the course seems to be v7.1.2 (edit: maybe they upgraded versions between lessons, not entirely sure)

from nest.

micalevisk avatar micalevisk commented on April 28, 2024

@StiliyanKushev yeah, got you

please feel free to improve the docs at https://github.com/nestjs/docs.nestjs.com

the version shouldn't matter here

from nest.

StiliyanKushev avatar StiliyanKushev commented on April 28, 2024

Well, I'm a bit worried that this is an issue? Either a bug, or outdated course information, but the fact it worked differently before makes me believe it's the former.

Just to recap, the course suggests that the above logs should execute 3 times (due to all provders instantiating because of the different internal hashes or whatever), however (on the latest nest version at least) it only executes once unless you specifically enable alwaysTransient.

from nest.

micalevisk avatar micalevisk commented on April 28, 2024

Just to recap, the course suggests that the above logs should execute 3 times

are you sure?

at 8:25
image

image

from nest.

StiliyanKushev avatar StiliyanKushev commented on April 28, 2024

at 9:08
image
image

from nest.

micalevisk avatar micalevisk commented on April 28, 2024

ok, I just saw what you're talking about

but please share a minimum reproduction as well

from nest.

micalevisk avatar micalevisk commented on April 28, 2024

check out the https://github.com/nestjs/nest/releases

I don't think that that behavior have changed but I can be wrong

from nest.

micalevisk avatar micalevisk commented on April 28, 2024

seems to be a regression introduced on @nestjs/[email protected]

from nest.

StiliyanKushev avatar StiliyanKushev commented on April 28, 2024

Great! Additionally I'd say this can be better documented for future reference as to me it seems to be a somewhat crucial feature in certain scenarios.

from nest.

kamilmysliwiec avatar kamilmysliwiec commented on April 28, 2024

We can basically revert the change for that module only, the easiest/quickest fix, the other changes we don't need to revert.

Would you like to create a PR for this?

from nest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.