Skip to content

Conversation

wololock
Copy link
Collaborator

This pull request provides a temporary fix for the issue of mutable actions. It turned out that the current client app fails with the following error:

core.js:6006 ERROR TypeError: Cannot add property publishedByUser, object is not extensible
    at AppEventBusService.publishAction (app.event-bus.service.ts:96)
    at TapSubscriber._tapNext (app.event-bus.effects.ts:22)
    at TapSubscriber._next (tap.js:40)
    at TapSubscriber.next (Subscriber.js:49)
    at FilterSubscriber._next (filter.js:33)
    at FilterSubscriber.next (Subscriber.js:49)
    at ScannedActionsSubject.next (Subject.js:39)
    at SafeSubscriber._next (ngrx-store-devtools.js:1467)
    at SafeSubscriber.__tryOrUnsub (Subscriber.js:183)
    at SafeSubscriber.next (Subscriber.js:122)

It happens in the following method, in the line where the action.publishedByUser is set.

    publishAction(action: RemoteAction) {
        if (!this.enabled) {
            return;
        }
        if (action.publishedByUser) {
            console.error('This action has already been published', action);
            return;
        }
        action.publishedByUser = this.currentUser;
        this.eventBusService.publish(action.eventBusAddress, action);
    }

The following code does not pass strictActionImmutability check, which is enabled by default. This temporal fix disables this runtime check, but at some point of time, we should consider refactoring the code to use only immutable actions as the documentation suggests:

https://ngrx.io/guide/store/configuration/runtime-checks

@wololock wololock requested a review from benorama July 14, 2021 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants