Skip to content

Firebase RTDB PERMISSION_DENIED when using compat in a worker #7841

@jdcoldsmith

Description

@jdcoldsmith

Operating System

Windows 11

Browser Version

Chrome (latest version)

Firebase SDK Version

10.6.0 (compat)

Firebase SDK Product:

Auth, Database

Describe your project's tooling

Polymer, Lit, Rollup, Vitest

Describe the problem

Since transitioning from v8 to the new modular versions (v9 and v10), I have noticed a strange bug when trying to use firebase/compat/app in a worker. When using the compat 10.6.0 version in a web worker I will call firebase.initializeApp with the correct credentials but the first call that is made to the Realtime Database results in a PERMISSION_DENIED error. The current workaround that I have found for this is to call firebase.auth() immediately after calling firebase.initializeApp and that seems to kick start authentication to work correctly. This bug only happens in a worker context. Previously, in v8 we were able to just call firebase.initializeApp and authentication would automatically link to the authentication of the client. Thank you for your time!

Here is the error that I am hitting:
image

Steps and code to reproduce issue

In a worker include these imports (firebase v10.6.0):

import firebase from 'firebase/compat/app';
import 'firebase/compat/database';
import 'firebase/compat/auth';

then call firebase.initializeApp(credentials_go_here) followed by an update
to the RTDB (example: await firebase.database().ref('test/path/here').update({'test': 'testing'});

This should result in the PERMISSION_DENIED error

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions