You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Why not refuse to start the program if two (or more) tagged errors used in an effect have the same _tag? #10843
It is mentioned in the docs that it is the developer's responsibility to make sure that the _tag of tagged errors used in an effect is unique... But this is super easy to miss!
What is the feature you are proposing to solve the problem?
I do understand that it is not possible to check if _tag of tagged errors used in a effect is unique or not in the compile time (I assume there is no graceful way to implement this yet in Typescript)...
I was thinking why not refuse to start the execution of a program (basically crashing it as soon as it starts) after checking if an effect uses two (or more) tagged errors with the same tag? Basically a quick check after the server starts in the dev mode... Can skip this check in the production (because servers needs to spin up as quickly as possible in production I assume).
I don't know if what I have proposed above is a graceful solution to this problem, but yesterday I encountered a flaw in business logic of my product because of tagged errors having same _tag value.
Also, If possible can you please tell me how do I handle this problem?
@KhraksMamtsov thanks, I will try to integrate the LSP that you have mentioned above.
But, since the Effect package exposes 'Data' module, why can't we use a Map or Set to make sure _tag of all instances of Data.TaggedError is unique?
constset=newSet<_tag>()classTaggedError{constructor(_tag: String){if(set.has(_tag)){}// refuse to create the a instance of TaggedError in runtime...set.add(_tag)}}export*asData
Activity
KhraksMamtsov commentedon Nov 22, 2026
Hey! You could use [@effect/language-service](https://github.com/Effect-TS/language-service/blob/main/README.md#configuring-key-patterns).
It provides the
deterministicKeysrule, which helps prevent accidental tag collisions by enforcing deterministic naming conventions for tags.KhraksMamtsov commentedon Nov 22, 2026
This problem cannot be fully solved at runtime, because when the program starts, we don't know which errors it might eventually produce.
It can be reduced to something like this:
At runtime, we'll only discover a collision if both functions happen to return
"B". This will happen in only 1 out of 4 possible combinations.shibisuriya commentedon Nov 23, 2026
@KhraksMamtsov thanks, I will try to integrate the LSP that you have mentioned above.
But, since the Effect package exposes 'Data' module, why can't we use a Map or Set to make sure _tag of all instances of Data.TaggedError is unique?