-
Notifications
You must be signed in to change notification settings - Fork 230
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
State symbols use a fully qualified id instead of symbol
?
#784
Comments
Keys could also be created with |
oh didn't know this was a thing, yeah that would do the trick. one part that would still be useful is maybe the fact that it scope the key automatically. |
You could still get unexpected behavior if you put stuff into state with one version of a library and get it out with another. Right now you fail to get anything out, but if you get out something with the wrong shape because the library changed the shape, it could still be hard to debug.
Is this mainly an issue in the language server / IDE? I mentioned in another issue about compiler version mismatch that it is possible to create multiple language server instances. Maybe we should do that. Or are there command line scenarios for a single project where this happens? I thought the peer dependencies were meant to resolve that? |
On balance, using Symbol.for or equivalent is better than status quo since it will work more often than not when the version changes, but the state doesn't in the common case. So I'm not pushing back, but it's not very satisfying to me that you could still get silent bad behavior when a library changes too much and you load two versions. |
@nguerrera it is also happening in the CLI, in this particular case we have this Maybe what we really need is the warning that if you load a library twice then it probably won't work but the workaround is still very hard to do and being able to just The other use case is: how the azure specs are going to be published in the azure-rest-api-specs repo vs consumed in the |
Ha, I closed #785 against this. I think it would be good if we did Symbol.for or equivalent and had a warning. We could maybe silence the warning if the version is the same but it got loaded twice from different physical locations. So it would work a lot of the time, but for that case where it behaves strangely, the warning would be a really helpful clue. |
It is definitely tricky enabling this and adding the warning with the exception that the same version is loaded opens the question but what if its just a one of version/another compatible one. Maybe that needs to be explicitly specified when running cadl(I explicitly allow version 0.31.1 and 0.31.2 to work together) |
I'm not confident in any scheme to declare which versions are compatible (either by convention like semver or some knob). My experience is that we always get it wrong and there's a breaking change where we don't expect one. But it feels like if we don't allow exact version than some scenarios like the cadl-ranch have no way to get clean on the warning. Or maybe it's the opposite, you silence the warning by declaring version ranges you're willing to consume? But that feels complicated. It seems like it can be annoying but should always be possible to line up the versions for production scenarios. And if you're just iterating with npm link, then you can just live with the warning? |
Yeah that's more what I was saying |
Given that right now it's totally broken even for same version, seems like we could start by allowing that and merely warning for the rest. Then see what issues remain over time? Basically, don't go add knobs to specify compatible ranges until we get some mileage on the initial change and see we need to go farther. Related: Can we relax the "compiler mismatch" error to warning on different version instead of error on different physical location if we do this. Or would it fall out as the same warning as this more general one? My intuition is that it's a lot easier to go hunting for different versions, then to ensure that everything resolves to the same path. Would you agree? |
Yeah compiler mistmatch also as long as we replace all our |
FWIW we went down this path before with tracing in Azure SDKs: https://github.com/Azure/azure-sdk-for-js/blob/47e53cc9f091bc33ccfc8f443b43fc40cb80a746/sdk/core/core-tracing/src/utils/cache.ts It was a bit of a pain because we had to remember to bump the version in the symbol name whenever we made breaking changes... and then somehow remember which package versions corresponded to which symbol versions. It wasn't very easy to catch mistakes. |
PR is here: #871 |
The issue with having different version of cadl libraries installed is happening so many times
This is happening a lot if you are trying to work on multiple cadl project at once and the only way around is to create a workspace to link all the package version together. I also think this make it that if you have a dep on package A and package B which both depends on different version of library C then this would not work.
Wondering that if we have a
createSymbol
helper that will create a unique key for the library using the library name (e.g.@cadl-lang/rest.route
)Proposal
Symbol('foo')
withSymbol.for("my-lib.foo")
createSymbol
(or other name) that can get created increateLib
similar toreportDiagnostic
) that can autoamtically add the library name to make sure the symbol is unique.The text was updated successfully, but these errors were encountered: