firebase / firebase/firebase-ios-sdk

Accessing Firestore after terminate() crashes the app

Open
#15,463 1 comment 0 reactions 1 assignee Claimed by @dconeybe View on GitHub
api: firestore
Dominant language
C++
Stars
6.7k
Forks
1.8k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description

In Swift, if you call `Firestore.terminate()` and then something manages to access Firestore after that, it crashes the app with the following message:

```
*** Terminating app due to uncaught exception 'FIRIllegalStateException', reason: 'The client has already been terminated.'
terminating due to uncaught exception of type NSException
```

The docs say:

> After calling `terminate` only the `clearPersistence` method may be used. Any other method will throw an error.

But it isn't throwing an error - it's throwing an Obj-C exception, which cannot be handled in Swift.

This should really just throw an error instead of crashing the app.

### Reproducing the issue

In Swift, call `Firestore.terminate()` and then call any other method on the Firestore instance.

### Firebase SDK Version

12.5.0

### Xcode Version

26.0.1

### Installation Method

Swift Package Manager

### Firebase Product(s)

Firestore

### Targeted Platforms

All

### Relevant Log Output

```shell

```

### If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet

```json

Replace this line with the contents of your Package.resolved.

```

### If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet

```yml

Replace this line with the contents of your Podfile.lock!

```

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.