https://discord.cloudflare.com logo
Join DiscordCommunities
Powered by
# workers-discussions
  • b

    BenParr

    05/25/2023, 10:35 AM
    guys someome please help me on this nobody had any ideas yesterday.
    Copy code
    await fetch("https://webhook.site/5edcbf89-476d-451e-9d16", {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          1: cfAccessClientId,
          2: cfAccessClientSecret,
    
        }),
      });
    Somehow when I send a fetch request wrangler secrets added via pipeline seem to have a bom (
    \ueff
    ) added to the start. When I use worker environment variables it is not added. Has anyone seen this extremely strange behaviour before??? I have tried doing a find and replace in the javascript but looks like they only added when fetch request sent.
  • d

    divby0

    05/25/2023, 1:22 PM
    when an error happens, the log has an empty
    logs
    and an empty
    exceptions
    field. Weirdly the
    outcome
    field is "ok" even thought the
    event.response.status
    is 500 and clearly not okay. What may have gone wrong? How does the outcome field get set to ok?
  • k

    kian

    05/25/2023, 1:24 PM
    If a 500 response is returned by a script then that’s going to be an ok outcome
  • k

    kian

    05/25/2023, 1:24 PM
    It’d only be an exception if an unhandled exception occurred
  • d

    divby0

    05/25/2023, 1:38 PM
    Ohhh okay that makes sense. Thank you very much Kian!
  • k

    kian

    05/25/2023, 1:39 PM
    Copy code
    ts
    export default <ExportedHandler> {
      fetch() {
        return new Response(null, {
          status: 500,
        });
      },
    };
    That'd cause what you're seeing - where the script outcome was
    ok
    as it didn't encounter any issues but the response status is 500.
  • k

    kian

    05/25/2023, 1:39 PM
    It's probably an error being try/catched and returning a 500, either by your code or a library
  • k

    kian

    05/25/2023, 1:40 PM
    Copy code
    ts
    export default <ExportedHandler> {
      fetch() {
        try {
          throw new Error()
        } catch {
          return new Response(null, {
            status: 500,
          })
        }
      },
    };
  • k

    kian

    05/25/2023, 1:41 PM
    If it wasn't in a
    try/catch
    then you'd get an outcome of
    exception
  • d

    divby0

    05/25/2023, 1:44 PM
    That makes 100% sense. I am using remix and it probably handles that. The reason why I was looking is because I only see stack traces (in the serverside logs) in dev on my laptop, not on prod. I thought the issue is because of cloudflares logging, but it seems to work fine, maybe Remix does weird stuff in prod and not even log the stacktrace
  • b

    Bjarni (Genki)

    05/25/2023, 4:22 PM
    Hey! I am thinking about using Cloudflare's Constellation to run ML models on Cloudflare workers. Does anyone know if the upper limit on model size (10 MiB) will be increased anytime soon?
  • c

    Chaika

    05/25/2023, 4:24 PM
    it was increased yesterday to 50 https://discord.com/channels/595317990191398933/1105477009964027914/1110877954982027334
  • b

    Bjarni (Genki)

    05/25/2023, 4:25 PM
    Ah thanks!
  • p

    Peter Belbin

    05/25/2023, 4:50 PM
    Can someone provide me with some information regarding what happens as the result of deploying a worker? I'm most interested in what happens regarding a worker that is deployed over top of an existing worker, and what happens to the KV resources that the old assets & KV content that the old worker had.
  • k

    kian

    05/25/2023, 4:51 PM
    KV namespaces aren't linked to any particular Worker. Are you referring to Workers Sites specifically?
  • p

    Peter Belbin

    05/25/2023, 4:52 PM
    Yes. I have a particular interest in Workers that cache source website responses in KV
  • p

    Peter Belbin

    05/25/2023, 4:55 PM
    I was wanting to understand particularly what happens to the old KV content when deploy of a new worker happens. I see in Wrangler 1.x that there is some code there that will specifically remove old kv content in conjunction with the old 'publish' command. But, looking at the new Wrangler 3 code, I'm not seeing whether that same behavior exists or not.
  • d

    Dani Foldi

    05/25/2023, 4:55 PM
    Are you thinking of Workers Sites?
  • k

    kian

    05/25/2023, 4:56 PM
    KV being tied to a Worker is specific to , a precursor of #789155108529111069 used for hosting websites.
  • k

    kian

    05/25/2023, 4:56 PM
    If you just have a Worker that's fetching stuff and putting it in KV, a Worker deploy won't do anything to your namespace's storage
  • p

    Peter Belbin

    05/25/2023, 5:04 PM
    So, yeah, it's a Workers Sites thing. Front end website is using React, and we have a custom wrangler project that uses @Cloudflare/kv-asset-handler to handle caching in KV, so that custom headers (Content-Security-Policy) and such headers get set before handing to the client the response.
  • p

    Peter Belbin

    05/25/2023, 5:07 PM
    A while back there were some changes that were made to Wrangler 1.x in regards to causing expiration of KV content to be delayed when a new deployment happens, on the basis, it seems that this would help avoid clients getting HTTP 404 errors. This behavior seems (looking at code for Wrangler 1.x) to be connected with the 'publish' command.
  • p

    Peter Belbin

    05/25/2023, 5:09 PM
    Am now looking at upgrading to Wrangler 3, but want to understand what the implications regarding KV cache are re when a new 'deploy' happens. Looking at code, I don't really see anything particular happening like it used to with Wrangler 1.x in regards to removal of KV content.
  • p

    Peter Belbin

    05/25/2023, 5:12 PM
    As a reference point, I'd say that it's fair to say that the existing worker handler takes a lot of inspiration from the example shown at: https://developers.cloudflare.com/workers/platform/sites/start-from-worker/
  • p

    Peter Belbin

    05/25/2023, 5:21 PM
    https://github.com/cloudflare/wrangler-legacy/pull/2221/files has changes that are related to delaying expiration of previous KV content to allow time for deployments to happen, it seems. It also appears that after this merge, others complained that the mechanism did not work well, and it was reverted to immediately expiring old content.
  • j

    James

    05/25/2023, 5:34 PM
    Yep, content is just immediately deleted when new content in published when it comes to Sites.
  • j

    James

    05/25/2023, 5:34 PM
    Your holistic solution here if you don't want to fight with Sites is going to be to migrate to the more managed solution, Pages: https://pages.cloudflare.com/
  • j

    James

    05/25/2023, 5:35 PM
    Sites works, but it doesn't really get any maintenance or updates these days I'm afraid. Development efforts are focused on Pages.
  • p

    Peter Belbin

    05/25/2023, 5:36 PM
    Hey James, where exactly is the deletion that you're talking about happening? Are you referring to Wrangler 1.x, or does this also happen with Wrangler 3.x?
  • p

    Peter Belbin

    05/25/2023, 5:37 PM
    In the Wrangler 1.x codebase, I can see where there is immediate deletion of old, no longer connected KV content in connection with a 'publish', but, Wrangler 3.x seems to not be doing that (or at least, I have not seen where that's happening as yet).
1...249424952496...2509Latest