Cloudflare Containers, durable objects
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Describe the feature
I would like to be able to use Cloudflare Containers in a project with Nitro. Configuring wrangler from own file or nuxt.config.ts works fine. I can make use images and bindings.
The problem is that the export must be in the main bundle and not chunks, hence the error:
Your Worker depends on the following Durable Objects, which are not exported in your entrypoint file: MyContainer.
This is generally not a problem of Containers itself. Generally every durable_object binding returns an error after building because it is not in the main bundle.
There is also an issue here: https://github.com/nitrojs/nitro/issues/3378
In the cloudflare_durable preset there is something like this: https://github.com/nitrojs/nitro/blob/v3/src/presets/cloudflare/runtime/cloudflare-durable.ts#L60
and it exports 1 binding, durable object with name $DurableObject, and with containers it needs to export somewhere in the route something like below. And while there is no error during build, there is an error during deploy because this export is not in the main bundle.
import { Container, getContainer } from "@cloudflare/containers";
export class MyContainer extends Container {
defaultPort = 4000; // Port the container is listening on
sleepAfter = "10m"; // Stop the instance if requests not sent for 10 minutes
}
Additional information
- Would you be willing to help implement this feature?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/presets/cloudflare/runtime/cloudflare-durable.ts around line 60 and compare the related issue 3378. Trace how durable-object bindings are included in the built entrypoint, then verify the Cloudflare Containers example and deployment behavior. Done means the required container or durable-object export is present in the main bundle and deployment no longer reports it missing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100