Class: ProxyFetchDO
Defined in: src/ProxyFetchDurableObject.ts:50
ProxyFetchDO - Durable Object that queues and processes external fetch requests
This DO provides a centralized service for executing external fetch() calls on behalf of other Durable Objects. By offloading fetch operations to this dedicated DO, other DOs avoid wall-clock billing while fetch requests are in flight.
Architecture:
- Single named instance ('proxy-fetch-global') handles all proxy fetch operations
- ULID-based FIFO queue ensures requests are processed in order
- In-flight tracking prevents duplicate processing
- Automatic retry with exponential backoff for transient failures
- Callback delivery to origin DO when complete
- Fire-and-forget mode supported (no callback)
Usage:
// From within another DO:
const reqId = await proxyFetchDO(
this, // DO instance
'https://api.example.com/data',
'MY_DO', // DO binding name
'handleApiResponse', // Handler method name
{ timeout: 10000 }
);
// Handler receives response:
async handleApiResponse(item: ProxyFetchHandlerItem) {
if (item.error) {
console.error('Fetch failed:', item.error);
} else {
* const response = decodeResponse(item.response);
const data = await response.json();
// Process data...
}
}
See
https://lumenize.com/docs/proxy-fetch/durable-object
Extends
DurableObject
Constructors
Constructor
new ProxyFetchDO(
ctx,env):ProxyFetchDO
Defined in: src/ProxyFetchDurableObject.ts:51
Parameters
ctx
DurableObjectState
env
any
Returns
ProxyFetchDO
Overrides
DurableObject.constructor
Properties
__DURABLE_OBJECT_BRAND
__DURABLE_OBJECT_BRAND:
never
Defined in: test/do/worker-configuration.d.ts:7767
Inherited from
DurableObject.__DURABLE_OBJECT_BRAND
ctx
protectedctx:DurableObjectState<{ }>
Defined in: test/do/worker-configuration.d.ts:7768
Inherited from
DurableObject.ctx
env
protectedenv:Env
Defined in: test/do/worker-configuration.d.ts:7769
Inherited from
DurableObject.env
Methods
alarm()
alarm():
Promise<void>
Defined in: src/ProxyFetchDurableObject.ts:83
Process the queue via alarm
Alarm is triggered automatically by Cloudflare when scheduled. Calls the shared queue processing logic.
Returns
Promise<void>
Overrides
DurableObject.alarm
enqueue()
enqueue(
request):Promise<void>
Defined in: src/ProxyFetchDurableObject.ts:66
Enqueue a request for async processing
Called by proxyFetchDO() client function to add a request to the queue. Generates a monotonic ULID for FIFO ordering and immediately processes the queue.
Parameters
request
Serialized request with metadata
Returns
Promise<void>
fetch()?
optionalfetch(request):Response|Promise<Response>
Defined in: test/do/worker-configuration.d.ts:7771
Parameters
request
Request
Returns
Response | Promise<Response>
Inherited from
DurableObject.fetch
triggerRecovery()
triggerRecovery():
Promise<void>
Defined in: src/ProxyFetchDurableObject.ts:93
TEST ONLY: Manually trigger orphaned request recovery
This method exists solely for testing. In production, recovery happens automatically in the constructor when a DO is evicted and reinstantiated.
Returns
Promise<void>
webSocketClose()?
optionalwebSocketClose(ws,code,reason,wasClean):void|Promise<void>
Defined in: test/do/worker-configuration.d.ts:7774
Parameters
ws
WebSocket
code
number
reason
string
wasClean
boolean
Returns
void | Promise<void>
Inherited from
DurableObject.webSocketClose
webSocketError()?
optionalwebSocketError(ws,error):void|Promise<void>
Defined in: test/do/worker-configuration.d.ts:7775
Parameters
ws
WebSocket
error
unknown
Returns
void | Promise<void>
Inherited from
DurableObject.webSocketError
webSocketMessage()?
optionalwebSocketMessage(ws,message):void|Promise<void>
Defined in: test/do/worker-configuration.d.ts:7773
Parameters
ws
WebSocket
message
string | ArrayBuffer
Returns
void | Promise<void>
Inherited from
DurableObject.webSocketMessage