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

    dave

    03/09/2023, 8:32 PM
    oh, I figured it out, it's because logs don't trigger until the worker is done?
  • d

    dave

    03/09/2023, 8:45 PM
    oh. I seem to be running into this bug
  • d

    dave

    03/09/2023, 8:59 PM
    huh are CF Worker threads blocking?
  • d

    dave

    03/09/2023, 8:59 PM
    I did a setTimeout and it never seems to be triggered while the end user is downloading a file.
  • l

    lattenb

    03/09/2023, 9:00 PM
    I'm running into issues trying to consume a enscripten-built WASM npm package from a JS worker. are there any examples out there? i see a couple articles from 2018, but they don't seem accurate or focused enough
    • 1
    • 3
  • s

    samdd

    03/09/2023, 9:22 PM
    Reposted as this is blocking me (and others) from using Cloudflare workers in production https://discord.com/channels/595317990191398933/1082037888184762408
  • d

    Dogs

    03/09/2023, 10:43 PM
    Is there any price comparison of workers vs a kubernatey at large scale? Cause from what I heard serverless gets a lot more expensive at scale
  • d

    dave

    03/10/2023, 12:01 AM
    kubernetes is a pain in the butt to scale yourself.
  • u

    Unsmart | Tech debt

    03/10/2023, 12:04 AM
    I mean obviously at some point running your own becomes cheaper serverless just makes it easy to scale indefinitely
  • u

    Unsmart | Tech debt

    03/10/2023, 12:05 AM
    Unless you have a decent sized engineering team you should probably not try to run your own k8s because while it may run fine when you first set it up once an issue happens you will lose all your sanity and a lot of money 😛
  • d

    dave

    03/10/2023, 12:58 AM
    yeeeeep
  • p

    PikaPika

    03/10/2023, 2:08 AM
    Anyone know how to send multiple files with Workers at once?
  • p

    PikaPika

    03/10/2023, 2:08 AM
    as mutipart form data
  • p

    PikaPika

    03/10/2023, 2:12 AM
    https://discord.com/developers/docs/reference#uploading-files
  • p

    PikaPika

    03/10/2023, 2:12 AM
    need to implement this in workers
  • p

    PikaPika

    03/10/2023, 2:12 AM
    anyone knows how?
  • c

    Chaika

    03/10/2023, 2:15 AM
    Workers support the normal FormData API https://developer.mozilla.org/en-US/docs/Web/API/FormData ex. for Discord, something like
    Copy code
    let formData = new FormData();
     formData.append("payload_json", embedBody);
     formData.append("files[0]", newTextBlob, "file1.txt");
     formData.append("files[1]", newTextBlob2, "file2.txt");
     let discordResponse = await fetch(env.DISCORD_WEBHOOK_URL, {
          method: "POST",
          body: formData,
        });
    You can use the .append method with a string (like in case of the payload_json embed information) and with Blob Larger example using Email Workers to sent to a Discord Webhook: Discord has its own file size limits as well
  • p

    PikaPika

    03/10/2023, 2:38 AM
    are you sure this would work?
  • d

    Dogs

    03/10/2023, 2:40 AM
    I mean yeah running ur own servers will almost always be cheaper at scale but I heard even running them on managed kubernetes like Google cloud run would be cheaper is that true?
  • c

    Chaika

    03/10/2023, 2:42 AM
    I mean, I use that (see the github link) to upload files and embeds to a Discord Webhook right now. I don't use multiple files, but as long as you're below the discord limit, should just be a matter of appending another blob to the formdata.
  • p

    PikaPika

    03/10/2023, 2:43 AM
    How to attach string as a file with filename filename.txt?
  • c

    Chaika

    03/10/2023, 2:45 AM
    Cloudflare has special pricing/contracts for Enterprise users, and I imagine the same for Google. I think at enough scale they would both work with you and get you customized pricing
  • c

    Chaika

    03/10/2023, 2:46 AM
    Something like
    Copy code
    formData.append("files[0]", value, "filename.txt");
  • d

    Dogs

    03/10/2023, 2:47 AM
    O nice, is there documentation on websites pricing also? Just a unrelated note
  • p

    PikaPika

    03/10/2023, 2:48 AM
  • p

    PikaPika

    03/10/2023, 2:48 AM
    There is a last problem
  • c

    Chaika

    03/10/2023, 2:48 AM
    For pay as you go pricing yea: https://developers.cloudflare.com/workers/platform/pricing/ CF does something interesting where they offer "Bundled" mode where you only pay for Requests and get a CPU Time (i.e you can await a network request without counting towards this). CF also offers "Unbound" pricing which is more like other serverless providers
  • p

    PikaPika

    03/10/2023, 2:49 AM
    how to make content disposition of payload_json as application/json ?
  • c

    Chaika

    03/10/2023, 2:52 AM
    Does it actually need that? I don't seem to be doing that and it still seems fine. I imagine you could just make it a blob with that type though
    Copy code
    js
          let embedBlob = new Blob([msg.toJSON()], {
            type: "application/json",
          });
        formData.append("payload_json", embedBlob);
  • c

    Chaika

    03/10/2023, 2:53 AM
    If you're having any trouble it might be to do with the library you are using, whatever that .toJSON() method is & the fact you are also adding the attachment back to the msg object
1...233223332334...2509Latest