Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[queues] correct DurableObject to DurableObjectNamespace & remove constructor block #14529

Merged

Conversation

helloimalastair
Copy link
Contributor

In the Env declaration for the Use Queues with Durable Objects example, the YOUR_DO_CLASS binding should be an instance of DurableObjectNamespace instead of DurableObject.

Constructor block for the YourDurableObject class contained an extra }, causing the fetch() to not be recognized. This block has been removed entirely, and the env been made public to match state

@github-actions github-actions bot added size/xs product:queues Cloudflare Queues: https://developers.cloudflare.com/queues labels May 12, 2024
@garysassano
Copy link
Contributor

Thanks for the PR.

There's a small snag with the fetch() call. Because it's within an if statement, TypeScript needs a return statement outside the if to cover cases where the condition isn't met. Otherwise, it throws a Function lacks ending return statement and return type does not include 'undefined' error, as the function might not always return the expected Promise<Response>.

@github-actions github-actions bot added size/s and removed size/xs labels May 12, 2024
@helloimalastair
Copy link
Contributor Author

@garysassano should be fixed, now returns a 400

Copy link
Contributor

@Maddy-Cloudflare Maddy-Cloudflare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to change the properties to be private.

content/queues/examples/use-queues-with-durable-objects.md Outdated Show resolved Hide resolved
Co-authored-by: Maddy <130055405+Maddy-Cloudflare@users.noreply.github.com>
@Maddy-Cloudflare Maddy-Cloudflare merged commit d65e82f into cloudflare:production May 14, 2024
6 checks passed
OKEAMAH pushed a commit to OKEAMAH/cloudflare-docs that referenced this pull request May 14, 2024
… constructor block (cloudflare#14529)

* correct `DurableObject` to `DurableObjectNamespace`

* remove constructor block and made `env` public

* add failure response

* Update content/queues/examples/use-queues-with-durable-objects.md

Co-authored-by: Maddy <130055405+Maddy-Cloudflare@users.noreply.github.com>

---------

Co-authored-by: Maddy <130055405+Maddy-Cloudflare@users.noreply.github.com>
@helloimalastair helloimalastair deleted the queues-durable-objects branch May 14, 2024 16:48
@helloimalastair helloimalastair restored the queues-durable-objects branch May 14, 2024 16:48
@helloimalastair helloimalastair deleted the queues-durable-objects branch May 14, 2024 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product:queues Cloudflare Queues: https://developers.cloudflare.com/queues size/s
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants