https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-help
  • Your worker created multiple branches of a single stream (for instance, by calling response.clone()
    g

    gadnuk_breaker_of_worlds

    12/19/2023, 7:05 PM
    I am getting this when trying to use a cloudflare worker together with the uploadthing library. I have debugged in VS-code and the error is thrown here when uploadthing library calls the safeParseJSON function: https://github.com/pingdotgg/uploadthing/blob/ea0f3c96f5db2fa945592d5efc06bf84811c5525/packages/shared/src/utils.ts#L233 Here is link to my cloudflare worker: https://github.com/kristiankauffeld/uploadthing-cf-worker
    k
    • 2
    • 4
  • How to setup billing notifications on Workers Paid Standard
    a

    Arnø

    12/20/2023, 8:22 AM
    I'm on the paid workers plan with standard usage model. How can I be notified when my usage exceed the monthly quotas ? In notifications section, I have only choice for bundled or unbound models, wich are deprecated. And is it possible to set notifications based on $ and not on CPU or requests count ?
  • Logpush log format is can't parse in Datadog
    p

    pigri

    12/20/2023, 5:22 PM
    I contacted with DataDog support. The answer is this:
    Copy code
    Thanks for reaching out to the Datadog support team! My name is Victorien and I'll handle your request from now on.
     
    After further investigation, this does appear to be a limitation from Cloudflare. Logs are sent as arrays of objects and sent as part of Workers Trace Events: https://developers.cloudflare.com/logs/reference/log-fields/account/workers_trace_events/.
     
    On our end, there is no option to split logs after ingestion. This action must be performed upstream. Therefore, I would suggest reaching out to Cloudflare to inquire whether they could eventually provide flexibility in the way logs are output.
     
    Alternatively, you could send your Cloudflare logs to a custom destination, split those logs on your end (with a script for example), and then forward these logs to Datadog (it could be achieved by using the Datadog Agent or our API: https://docs.datadoghq.com/logs/log_collection/?tab=host).
    Any ideas for this?
    k
    • 2
    • 2
  • Simple email worker
    r

    roger_57097

    12/21/2023, 7:06 AM
    Hi all I have a simple website on Pages and I'd like to send emails from the content form to myself. I've been looking at Email Workers and trying to work out if this is a viable option. The documentation doesn't seem very clear (to me). Does anyone have any example code to take the contents of a form and send it via an Email Worker? Any help would be much appreciated.
    j
    • 2
    • 5
  • Durable Objects query
    a

    amr21_

    12/21/2023, 10:19 AM
    Hello, do storage queries support nested keys? ex. storage looks like this:
    Copy code
    js
    {
    messages: {
         "mkey1": "....",
         "mkey2": "....",
         }
    }
    is it possible to just get mkey1 without getting all messages?
    n
    • 2
    • 2
  • Service Binding call resulting in TypeError
    u

    2adventure

    12/21/2023, 2:22 PM
    Hello, I'm currently working on implementing Service Bindings but I'm running into the following error when calling the ``fetch()`` of the service binding and passing on a string: ``TypeError: Fetch API cannot load: `` The Env interface:
    Copy code
    ts
    export interface Env {
        MY_SERVICE_BINDING: any;
    }
    The binding in the wrangler.toml:
    Copy code
    toml
    services = [
      { binding = "MY_SERVICE_BINDING", service = "the-worker-im-calling" }
    ]
    The service binding fetch call:
    Copy code
    ts
    const result = await env.MY_SERVICE_BINDING.fetch("MY-STRING");
    c
    • 2
    • 16
  • Is there any service interruption when I redeploy a worker?
    c

    c_bonadio

    12/21/2023, 3:59 PM
    Hi, when I redeploy a worker, is there any kind of service interruption for users of the old version of my worker? Thanks
    z
    c
    • 3
    • 3
  • The following routes were not configured to run with the Edge Runtime:
    u

    _arizmendi_

    12/22/2023, 4:33 AM
    i get this error, to solve i add "export const runtime = 'edge';" but i dont have - /_error in the project and idk how to solve this error for this route, this is an existent project for example this _not-found was solved just creating the tsx file but this dont work with _error build command npx @Cloudflare/next-on-pages
    f
    • 2
    • 1
  • How to enable unsafe eval in wrangler?
    c

    cyco130

    12/22/2023, 12:23 PM
    I see that unsafe eval and a other similar bindings have been implemened in workerd (https://github.com/cloudflare/workerd/pull/1338). Is it available in wrangler? If so, how do I enable the binding?
    k
    • 2
    • 2
  • Workers Routes Replacement
    w

    willin

    12/22/2023, 12:31 PM
    I want to create a workers route to:
    Copy code
    a.com/api/sth
    b.com/api/sth
    c.com/api/sth
    if worker does not have response, then fetch origin
    a.com/api/sth
    as result. how to write the fetch codes in the worker script?
    k
    • 2
    • 4
  • "InferenceUpstreamError: ERROR 3026: Unknown internal error" when calling Workers AI
    u

    2adventure

    12/22/2023, 9:47 PM
    I'm running into the error ``InferenceUpstreamError: ERROR 3026: Unknown internal error`` when calling Workers AI on version 1.0.47 (latest):
    Copy code
    ts
    const ai = new Ai(env.AI);
    const prompt = [
                { role: "system", content: "Prompt" },
                { role: "user", content: "Prompt" },
                { role: "assistant", content: "Prompt" },
    ]
    const result = await ai.run('@cf/meta/llama-2-7b-chat-int8', { messages: prompt });
    u
    • 2
    • 1
  • Have worker send specific headers
    f

    ftqo

    12/22/2023, 10:13 PM
    My worker works locally and in the dashboard, but is downloading a file called "download" in browser
    • 1
    • 2
  • empty worker
    t

    thatbeanlady

    12/23/2023, 2:07 AM
    i have followed through the create worker package process in the workers guide and it says it is complete however the folder contains no files such as index.js
  • Sentry for Handled Worker Exceptions
    s

    slowaspondwater

    12/23/2023, 2:53 AM
    Question about Sentry. > This integration allows you to connect to a Sentry project from your Worker to automcatically send errors and uncaught exceptions to Sentry with no code changes needed in the Workers application. I see that Sentry will capture unhandled exceptions but I'm wondering if Sentry will also be notified for handled exceptions? I guess I'm confused what
    send errors
    means in the docs above. I am hoping to enable this but unsure if that means I will need to bake in Sentry the old-fashioned way.
    e
    • 2
    • 5
  • Send an email from a static Pages website.
    n

    nosebleeeed

    12/23/2023, 10:03 AM
    Hello, I have a simple pages website on my account. The domain name is bought by another provider, but I have changed the DNS to point to Cloudflare and currently works as intended. My next goal is to start sending email from a form on my static Pages website using the domain as a sender - e.g. something like "no-reply@mydomain.com". The recepient should be on the same domain - e.g. "office@mydomain.com". The hosting that I was previously using has an SMTP that has those mailboxes available and usable is still up and running and I'm using them. My question is how can I leverage that and start sending mails from the Pages website?
    c
    j
    • 3
    • 2
  • Workers AI Error
    a

    angusma

    12/23/2023, 3:09 PM
    Sometimes the Workers AI will throw a SyntaxError, but it doesn’t always fail, It usually succeeds. Code part about Workers AI:
    Copy code
    js
    const ai = new Ai(env.AI);
    const output =  ai.run('@cf/meta/llama-2-7b-chat-int8', {
      prompt: args.prompt
    }).then(function (result){
      return result;
    }).then(async function (result){
      await fetch('https://discord.com/api/v10/webhooks/'+env.DISCORD_APPLICATION_ID+'/'+interaction.token+'/messages/@original',{
          method:'PATCH',
          headers:{'content-type': 'application/json;charset=UTF-8',},
          body:JSON.stringify({
              content: result.response,
          })
      })
    })
    The error (root directory path replaced with PROJECT_DIR):
    Copy code
    ✘ [ERROR] Uncaught (in promise) SyntaxError: Unexpected token 'E', "ERROR 3026"... is not valid JSON
    
          at async InferenceSession.run
      ({PROJECT_DIR}/.wrangler/tmp/dev-5g4ZDx/server.js:6124:26)
          at async Ai.run
      ({PROJECT_DIR}/.wrangler/tmp/dev-5g4ZDx/server.js:6192:30)
    
    
    ✘ [ERROR] Uncaught (async) SyntaxError: Unexpected token 'E', "ERROR 3026"... is not valid JSON
    t
    • 2
    • 2
  • Google IAP for TCP forwarding webhook
    d

    devced_46565

    12/24/2023, 1:41 AM
    Hi, Can we update our worker.js script to include a connect() function that returns a TCP socket, i.e., Google IAP for TCP forwarding webhook between Cloudflare Worker and an internal ip address hosting our SMTP server at ‘imap-cfored-com:10025.’, https://developers.cloudflare.com/workers/runtime-apis/tcp-sockets/#connections-to-port-25-are-prohibited Regards, Hal
    h
    h
    • 3
    • 2
  • Disable swaggerUI in production env
    g

    G4G4N

    12/24/2023, 10:04 AM
    What is the optimal way of disabling access to SwaggerUI in production environment? Currently I'm doing const router = env.ENVIRONMENT === 'local' ? OpenAPIRouter() : Router()
    u
    • 2
    • 1
  • Why there is no documentation that I can authenticate my tunnels using "globalThis.CF_CLIENT_ID"?
    t

    trader

    12/24/2023, 11:32 AM
    Such as using:
    Copy code
    ts
    // Add Cloudflare Access Service Token credentials as global variables, used when Worker
    // establishes the connection to Cloudflare Tunnel. This ensures only approved services can
    // connect to your Tunnel.
    declare global {
        var CF_CLIENT_ID: string | undefined;
        var CF_CLIENT_SECRET: string | undefined;
    }
    
    globalThis.CF_CLIENT_ID = CF_SERVICE_CLIENT_ID;
    globalThis.CF_CLIENT_SECRET = CF_SERVICE_CLIENT_SECRET;
    
    ...
    Not always an easy access to Fetch API is available. For example when using vector databases' client etc. 🙂
    c
    • 2
    • 1
  • Mail Routes I want to forward all mail recive
    i

    Iron_Max

    12/25/2023, 4:46 PM
    I want to forward all mail recived to
    support@domain.com
    to multiple mails
    1mail@gmail.com
    ,
    2mail@gmail.com
    ,
    3mail@gmail.com
    u
    c
    • 3
    • 31
  • Can't get wrangler to work with SSL certs
    b

    bnowak_83546

    12/25/2023, 6:25 PM
    Ok, so I have a following dev setup: * nginx reverse proxy as an entry point * pointed at at a worker * worker talks to a bunch of microservices depending on a route * everything wrapped in docker-compose Since in this setup, worker->microservice communication was over http, I've never hit the problem until I've tried to use Honeycomb observability plugin, which I assume talks over https with the mothership. As soon as I've added the plugin, I've started getting the dreaded TLS error:
    Copy code
    workerd/jsg/util.c++:281: error: e = kj/compat/tls.c++:221: failed: TLS peer's certificate is not trusted; reason = unable to get local issuer certificate
    Later validated that indeed any https call from within the worker will trigger the error. What I've tried so far to solve it: * in my
    wrangler.toml
    make
    local_protocol = "https"
    * replace my package.json run script
    wrangler.dev
    with
    NODE_EXTRA_CA_CERTS=/absolute/path/to/fullchain.pem wrangler dev
    Does not seem to help, despite the internet search(es) saying it should. Other useful info: * wrangler version:
    ^3.22.1
    * local ssl cert is a valid one from Letsncrypt/certbot, and nginx/browser have no issues with it. * relevant bits of Dockerfile:
    Copy code
    FROM node:20-slim as platform-dev
    do stuff
    RUN apt-get install procps openssl -y
    Any advice would be appreciated. Thanks
  • Cloudflare Worker Deployment Branch URLs
    j

    justjumper_

    12/25/2023, 9:38 PM
    Is it possible to have individual branch URLs for cloudflare workers deployments (similar to Cloudflare Pages)? Unfortunately cannot use Cloudflare Pages for this particular project as it requires smart placement. Thank you!
    k
    • 2
    • 2
  • Cloudflare worker fetch returning stale data in production
    x

    xarvinss

    12/26/2023, 11:15 PM
    Hi team, when I call my worker from my local machine to it's prod URL, an external API i'm calling using fetch returns an empty array which is expected. However, when a server hosted on AWS calls this cloudflare worker which then calls an external API, it starts returning stale data. I'm not sure why this is happening. This is how I've been calling the fetch let response = await fetch(url, { method: options.method, headers: { Authorization:
    Bearer ${env.API_KEY}
    , 'User-Agent': 'CF-Worker-API-Client/1.0', 'Cache-Control': 'no-cache, no-store, must-revalidate', }, cf: { cacheTtl: -1 // Bypass Cloudflare's cache } });
  • Within worker DNS resolution is failing
    p

    plopix

    12/27/2023, 12:56 AM
    Hello, I am pretty confident that my worker when it is reached through its custom domain. Y.Z.com is unable to resolve X.Z.com. - Zone is not entirely managed by Cloudflare (partial CNAME setup) - Y.Z.com is reachable and worker is running correctly. (just DNS resolution is broken) - X.Z.com is managed on AWS - when reached via it's worker.dev route, DNS resolution is working. I have logs and proofs of all that. Any help? I can't be the only one with that error? Either I do something weird or it's a bug somewhere. Thanks This doc says it should work: https://developers.cloudflare.com/workers/configuration/routing/custom-domains/#:~:text=On%20the%20same%20zone%2C%20if,succeed%20without%20a%20service%20binding
    c
    • 2
    • 26
  • SSH Tunnel Commands
    c

    cfored

    12/27/2023, 1:38 AM
    Hi, Using my Pro Business Account with enabled SSH (one app allowed), how do I enable an SSH command to connect to my GCP VM instance (imap-cfored-com) via (1) Cloudflare Worker (i.e., JavaScript: work.js: UI) and (2) Cloudflare Wrangler (Local CLI)? Regards, Hal
    f
    • 2
    • 1
  • Worker 522 with custom domain name
    w

    willin

    12/27/2023, 3:42 AM
    Error 522 occurs when Cloudflare times out contacting the origin web server. Two different timeouts cause HTTP error 522 depending on when they occur between Cloudflare and the origin web server: https://redirect-willin-love.willin.workers.dev/ --> works https://demo.willin.love/ --> 522
    e
    • 2
    • 17
  • Fetch Request Returns 'Undefined' during File Upload Polling Process"
    g

    gadnuk_breaker_of_worlds

    12/27/2023, 9:43 AM
    I am experiencing an issue with my Cloudflare Worker that is part of a file upload process using the UploadThing library. The worker is responsible for polling the upload status from an external server (https://uploadthing.com/api/pollUpload/...). However, I'm encountering a problem where the polling doesn't happen and the fetch request within the worker therefore does not return a response, resulting in an 'undefined' value. Below is a summary of the process and where the issue occurs: 1. A POST request is initiated to http://localhost:3000/api/uploadthing?actionType=upload&slug=videoAndImage. 2. This triggers the buildRequestHandler function within UploadThing, which parses the request and forwards it to https://uploadthing.com/api/prepareUpload. 3. Upon receiving a successful response from UploadThing, the conditionalDevServer function called in buildRequestHandler initiates a polling process using pollForFileData. 4. pollForFileData, wrapped with withExponentialBackoff, makes a fetch request to https://uploadthing.com/api/pollUpload/... to check the upload status. 5. The fetch request is configured with the necessary headers, including an API key and SDK version. 6. However, the polling doesn't happen, and the fetch request does not return any response, resulting in 'undefined'. I have attached a video demonstrating the issue, where I step through the execution using a debugger. Additionally, here is the link to a pull request (PR) that is currently being worked on in the UploadThing repository: https://github.com/pingdotgg/uploadthing/pull/514/commits This PR contains relevant code changes that might provide further insights into the issue. I am looking for insights into why the polling doesn't return a response. Any suggestions on troubleshooting steps, potential causes, or configuration changes that could resolve this issue would be greatly appreciated. Thank you in advance for your help
    pollforfiledata
    • 1
    • 1
  • Debugging O2O locally
    e

    Eezergoode

    12/27/2023, 11:03 PM
    I'm building a worker that uses O2O to Shopify and I'm curious how I can debug this locally. I use
    fetch(request)
    which forwards the request on to the origin (Shopify) but locally it it won't know where the origin is. If I overwrite the url to fetch from Shopify it will hit my worker in production. How are others working around this w/ O2O?
    e
    • 2
    • 1
  • Transactional Storage billing
    e

    Erisa | Support Engineer

    12/28/2023, 11:40 AM
    Billing happens at the account level, transactions are totalled across all instances/objects
    a
    c
    • 3
    • 3
  • form data with itty-router-openapi
    c

    colearendt

    12/28/2023, 12:29 PM
    I have a form submission going through a worker built with itty-router-openapi. If I submit the data via a POST request with standard
    application/json
    , everything works swimmingly. Use
    data.body
    just like the examples, etc. However, if I submit the data as a
    application/x-www-form-urlencoded
    , then I get nothing. Moreover, if I try to read
    FormData()
    off of the request, then I get "body has already been read." Presumably the body is read during the body sanitization / verification / schema-matching done by itty-router. Any recommendations for which direction to go here? Is there a way to access
    FormData
    through
    itty-router-openapi
    ? https://github.com/cloudflare/itty-router-openapi
    • 1
    • 1
1...678910Latest