# DEADLINE_EXCEEDED: The deadline expired before the operation could complete. gRPC stream closed with status code 4

- **ID:** `cloud/gcp-pubsub-subscription-pull-ack-deadline-exceeded`
- **Domain:** cloud
- **Category:** runtime_error
- **Error Code:** `DEADLINE_EXCEEDED`
- **Verification:** ai_generated
- **Fix Rate:** 82%

## Root Cause

Pub/Sub subscriber's ack deadline is too short for message processing, causing the gRPC streaming pull to close after repeated deadline violations.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| gcloud_cli | active | — | — |
| pubsub_api | active | — | — |
| client_library | active | — | — |

## Workarounds

1. **Increase the ack deadline for the subscription: `gcloud pubsub subscriptions update my-sub --ack-deadline=600` (10 minutes). Ensure your message processing completes within this window.** (90% success)
   ```
   Increase the ack deadline for the subscription: `gcloud pubsub subscriptions update my-sub --ack-deadline=600` (10 minutes). Ensure your message processing completes within this window.
   ```
2. **Implement a manual ack extension loop in your subscriber: after receiving a message, call `subscriber.modifyAckDeadline(message, 60)` every 30 seconds until processing is done, then ack. Example: `from google.cloud import pubsub_v1; subscriber.modify_ack_deadline(subscription, [message.ack_id], 60)`** (95% success)
   ```
   Implement a manual ack extension loop in your subscriber: after receiving a message, call `subscriber.modifyAckDeadline(message, 60)` every 30 seconds until processing is done, then ack. Example: `from google.cloud import pubsub_v1; subscriber.modify_ack_deadline(subscription, [message.ack_id], 60)`
   ```

## Dead Ends

- **** — Adding more subscribers doesn't fix the ack deadline; each message still has the same processing time limit. (75% fail)
- **** — Synchronous pull has its own timeout issues and doesn't inherently increase ack deadline. (60% fail)
