firebase / firebase/firebase-js-sdk

runTransaction doesn't work in Chrome extension MV3

Open
#6,483 15 comments 1 reaction 1 assignee Claimed by @MarkDuckworth View on GitHub
api: firestore api: storage feature request v9
Dominant language
TypeScript
Stars
5.1k
Forks
1k
Avg merge
2d 21h
Merged PRs (30d)
37

Description

* Operating System version: Ubuntu 20.04.3 LTS
* Browser version: 102.0.5005.61
* Firebase SDK version: 9.6.5
* Firebase Product: firestore
* Chrome extension: VM3

### The problem
I can't use `runTransaction` in Chrome extension MV3 as it [doesn't support](https://developer.chrome.com/docs/extensions/mv3/migrating_to_service_workers/#workers) `XMLHttpRequest`. All other commands work well.
I found that it was [fixed](https://github.com/firebase/firebase-js-sdk/pull/4939) on GH (for some reasons, not for transactions).

#### Steps to reproduce:
```javascript
let userRef = doc(db, 'users', userInfo.id);
runTransaction(db, transaction => {
return transaction.get(userRef).then(userDoc => {
return transaction.update(userRef, { 'eventName': 42 });
});
});
```
I got an error: `Uncaught (in promise) FirebaseError: ReferenceError: XMLHttpRequest is not defined`

My assumption is that V9 still uses `XMLHttpRequest` in `runTransaction`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.