When deleting platform workers, the dispatch worker appears to serve the dispatch worker for a brief period of time. This results in unexpected behavior from a platform tenant's perspective where they may observe their worker serving requests.
Update from Cloudflare: Deletes are not instant and sometimes take around a minute to completely clean up, even if deployments are under the "all-at-once" deployment model. The recommended approach would be to stop routing requests to the deleted platform worker yourself, which may involve some state such as KV to track who has entered this delete state.
- Create the dispatch namespace
yarn dispatch-namespace:create
- Create a platform worker
yarn platform-worker:create
- Create a platform worker
yarn platform-worker:create
- Request through dispatch worker (https://dispatch-worker-example.REDACTED.workers.dev/platform-worker-example)
- Observe an expected 200 response when routing to the deployed platform worker
- Request through dispatch worker (https://dispatch-worker-example.REDACTED.workers.dev/something-that-doesnt-exist)
- Observe an expected 404 response when routing to the non-existent platform worker
- Delete the platform worker. Note, the
wranglerCLI does not allow you to delete platform workers. Must use the Cloudflare API.curl --request DELETE \ --url https://api.cloudflare.com/client/v4/accounts/REDACTED/workers/dispatch/namespaces/cf-wfp-delete-example/scripts/platform-worker-example \ --header 'Authorization: Bearer REDACTED' - Observe successful response.
- (Optional) Observe that the platform worker no longer exists in the UI.
- Request through dispatch worker (https://dispatch-worker-example.REDACTED.workers.dev/platform-worker-example)
- Observe a 200 response when routing to the deleted platform worker
- Observe a 404 response when routing to the deleted platform worker
When deploying updates to a platform worker, I seem to get routed to the updated version almost immediately. This differs from delete behavior where the change is not immediate.
Introducing CDN caching further complicates issues the tenant may have especially when cache-control behavior is origin-based. The window of time in which the deleted platform worker is still served allows longer lived cache responses to be created that may have TTLs extending beyond the time in which it takes to delete the platform worker.