Skip to content

createEffect implementation details are leaking #4971

@JeanMeche

Description

@JeanMeche

Which @ngrx/* package(s) are the source of the bug?

effects

Minimal reproduction of the bug/regression with instructions

This has already been reported by #3052, I understand the behavior and why It's not recommended to do that,

I think the implementation details of createEffect leak when the return returns a symbol.

myEffect = createEffect(() => {
  if(someCondition) {
     return EMPTY. 
  }
  ... 
});

or also

const obs:Observable<any> = new Observable();

const eff1 = createEffect(() => obs);
const eff2 = createEffect(() => obs);

Both codes throw Cannot redefine property: __@ngrx/effects_create__, which is basically an implementation detail of the createEffect function that would happen if defineProperty had the option configurable: true by default.

For the sake of compleness, this issue doesn't arise when the Zone.js legacy patch is loaded which changes the behavior of Object.defineProperty, see angular/angular/issues/37432

Expected behavior

The error should be more explicit / or it shouldn't error at all.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions