mooon
mooon
Explore posts from servers
CDCloudflare Developers
Created by mooon on 8/14/2023 in #workers-help
A hanging Promise was canceled - Rust
Hey there, I'm using cloudflare workers with the worker crate. I have a route that looks like so:
pub async fn create_payment_link(mut req: Request, ctx: RouteContext<()>) -> Result<Response> {
println!("Request received");
let request_ok = verify_request(&ctx, &req);
println!("request ok: {request_ok:?}");
if !request_ok {
Response::error("Invalid Authorization", 403)
} else {
let data: CreatePaymentLink = req.json().await?;
let link = StripeClient::create_payment_link(&ctx, &data.price_id).await?;
Response::ok(link)
}
pub async fn create_payment_link(mut req: Request, ctx: RouteContext<()>) -> Result<Response> {
println!("Request received");
let request_ok = verify_request(&ctx, &req);
println!("request ok: {request_ok:?}");
if !request_ok {
Response::error("Invalid Authorization", 403)
} else {
let data: CreatePaymentLink = req.json().await?;
let link = StripeClient::create_payment_link(&ctx, &data.price_id).await?;
Response::ok(link)
}
the StripeClient::create_payment_link internally uses worker::Fetch::Request. Let me know if it would help if I also provided the the code for this. I get an error that looks like so whenever the route is requested (currently testing locally):
A hanging Promise was canceled. This happens when the worker runtime is waiting for a Promise from JavaScript to resolve, but has detected that the Promise cannot possibly ever resolve because all code and events related to the Promise's I/O context have already finished.
✘ [ERROR] Uncaught (in response) Error: The script will never generate a response.
A hanging Promise was canceled. This happens when the worker runtime is waiting for a Promise from JavaScript to resolve, but has detected that the Promise cannot possibly ever resolve because all code and events related to the Promise's I/O context have already finished.
✘ [ERROR] Uncaught (in response) Error: The script will never generate a response.
I'm using worker = 0.0.18
1 replies
CDCloudflare Developers
Created by mooon on 7/30/2023 in #workers-help
Attempting to make a rust worker makes a JS one
Hi there I'm using the npm init cloudflare mw_image_function worker-rust command to make a rust worker but it ends up making a javascript one instead of a rust one, anyone know why?
3 replies
CDCloudflare Developers
Created by mooon on 4/29/2023 in #workers-help
Cannot read properties of undefined (reading 'fetch')
8 replies