Skip to content

Behavior-breaking change introduced in patch 2.5.3: Container.reset now resets defaultScope #319

@Mr-Alirezaa

Description

@Mr-Alirezaa

Hi,

In the 2.5.3 changelog, there’s a note stating:

  • Container.reset should also reset defaultScope and promiseTriggersError.

While this may seem like a minor internal adjustment, it introduces a behavior-breaking change that can significantly impact existing codebases. Specifically, resetting a container now unexpectedly resets defaultScope, which was not the case before.

This change is problematic for two reasons:
1. Unexpected Side Effect: The name defaultScope does not imply that it would be reset as part of a Container.reset() call. Developers typically expect reset() to clear registered services or state, but not to modify the container’s configuration or intended usage patterns like scope behavior.
2. Violation of Semantic Versioning: This was introduced in a patch version. Patch releases are expected to be safe upgrades that fix bugs without introducing new behavior or breaking existing ones. In this case, the change silently altered runtime behavior and caused issues in production for us, which we only discovered through side effects.

Impact

This change broke expected behavior in our app. Here’s a simplified example:

public final class NetworkContainer: SharedContainer {
    public static let shared = NetworkContainer()
    public let manager = ContainerManager()

    public init() {
        manager.defaultScope = .cached
    }
}

Previously, dependencies resolved from NetworkContainer remained cached as intended. After upgrading to 2.5.3, calling reset() cleared the defaultScope back to .unique, which meant our dependencies were no longer cached — resulting in subtle bugs and inconsistent state.

Request

Please reconsider this change and how it was introduced. At the very least, such behavior changes should be reserved for a minor or major release, and should be more clearly documented as potentially breaking. In its current form, this violates the expectations developers have from patch versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions