question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sendEmailVerification() - Cannot assign to read only property '_canInitEmulator

See original GitHub issue

Hi, I’ve spent so much time without finding the answer so I assume it could be a bug. After creation of a new user by createUserWithEmailAndPassword() I’m calling current user from AngularFireAuth instance. Then I call sendEmailVerification() which causes an error:

TypeError: Cannot assign to read only property '_canInitEmulator' of object '[object Object]'
    at index-839de510.js:937
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (asyncToGenerator.js:3)
    at _next (asyncToGenerator.js:25)
    at asyncToGenerator.js:32
    at new ZoneAwarePromise (zone.js:1387)
    at asyncToGenerator.js:21
    at _performFetchWithErrorHandling (index-839de510.js:936)
    at index-839de510.js:913
    at Generator.next (<anonymous>)

It happens for angular 12 and 13. Angular: 13.1.0 Firebase: 9.4.0 Angularfire: 7.2.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
MarcinBorkowski03commented, Dec 2, 2022

@mikalcallahan

I didn’t see your code, but probably the error occurs when you pass User object (which you get from calling createUserWithEmailAndPassword) to signupSucces. I had the same problem and I solved it as suggested in this thread: signout function in ngrx effect with() #3251

So I created an interface for user details like this to avoid using User interface from firebase:

interface UserInfo {
  displayName: string | null;
  email: string | null;
  phoneNumber: string | null;
  photoURL: string | null;
  providerId: string;
  uid: string;
}

I added also User parsing method

const parseUser = ({
  displayName,
  email,
  phoneNumber,
  photoURL,
  providerId,
  uid,
}: User): UserInfo => ({
  displayName,
  email,
  phoneNumber,
  photoURL,
  providerId,
  uid,
});

And finally my signup effects look like this:

signup$ = createEffect(() =>
  this.actions$.pipe(
    ofType(AuthActions.authSignupActions.start_signup),
    switchMap(({ signupCredentials }) =>
      this.authService.signupUser$(signupCredentials).pipe(map(parseUser))
    ),
    map(() => AuthActions.authSignupActions.done_signup({ user }))
  )
);
1reaction
JakubRoszkowskicommented, Dec 19, 2021

@artask @Sapython provideAuth was added during automatically installation so there’s no thing I could change at my code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Cannot create property '_canInitEmulator' on string ...
With new firebase functional approach, you need to include auth parameter like this: createUserWithEmailAndPassword(auth, email, password).
Read more >
auth package - JavaScript API reference - Firebase - Google
UserInfo, User profile information, visible only to the Firebase ... Adds a blocking callback that runs before an auth state change sets a...
Read more >
firebase: Cannot assign to read only property 'displayName' of ...
I was trying to create a function where users can update their names and avatar photos. For which I used updateProfile() function. But...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found