# MongoServerError: ChangeStream: resume token from before the collection drop is invalid

- **ID:** `mongodb/change-stream-resume-from-before-drop`
- **Domain:** mongodb
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

A change stream attempted to resume using a resume token that predates a collection drop, which invalidates the token because the namespace was recreated.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| MongoDB 5.0 | active | — | — |
| MongoDB 6.0 | active | — | — |
| MongoDB 7.0 | active | — | — |

## Workarounds

1. **Listen for 'drop' events in the change stream cursor and save a new resume token after the collection is recreated: const cursor = db.watch(); cursor.on('change', (change) => { if (change.operationType === 'drop') { // wait for collection recreation and save new token } })** (85% success)
   ```
   Listen for 'drop' events in the change stream cursor and save a new resume token after the collection is recreated: const cursor = db.watch(); cursor.on('change', (change) => { if (change.operationType === 'drop') { // wait for collection recreation and save new token } })
   ```
2. **Restart the change stream from the latest event after a drop by not providing a resume token: db.watch() without resumeAfter** (95% success)
   ```
   Restart the change stream from the latest event after a drop by not providing a resume token: db.watch() without resumeAfter
   ```
3. **Store the resume token in a separate collection and implement a fallback to start from 'now' if the token is invalid: try { db.watch({ resumeAfter: savedToken }) } catch (e) { if (e.code === 280) { db.watch() } }** (90% success)
   ```
   Store the resume token in a separate collection and implement a fallback to start from 'now' if the token is invalid: try { db.watch({ resumeAfter: savedToken }) } catch (e) { if (e.code === 280) { db.watch() } }
   ```

## Dead Ends

- **** — The drop event changes the namespace's history, making pre-drop tokens invalid. (100% fail)
- **** — Resume tokens are tied to the namespace and oplog position. (90% fail)
- **** — The error is caused by the drop event, not by oplog expiration. (95% fail)
