Skip to content

need to return the promise and await for it to execute, or it doesn't work in stateless environments (cloudflare workers) #22

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mansimransingh
Copy link

No description provided.

Copy link
Member

@nikme nikme left a comment

Choose a reason for hiding this comment

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

Care to explain the setup where this was not executed? The idea behind our SDKs is to have as little impact as possible on the execution time.
This will add a slight delay.

@nikme nikme self-assigned this Apr 30, 2025
@mansimransingh
Copy link
Author

mansimransingh commented Apr 30, 2025

We’re using this in Cloudflare module worker + hono.

This change is pretty lazy tho and yes does have impact on execution time.

Once I get some time, ideally we could do
ctx.waitUntil(sendToTreblle)

and return the response immediately.

this would ensure Cloudflare context isn’t destroyed until treblle request completes but won’t block api response to client

@mansimransingh
Copy link
Author

@nikme updated to add waitUntil - this will be non-blocking (return response immediately) and will extend cloudflare context run time until treblle call is executed.

@nikme nikme self-requested a review May 9, 2025 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants