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

    dkfdkdodkms

    05/16/2023, 4:07 PM
    nice, but i would rather them invest in fixing what's broken
  • a

    AA

    05/16/2023, 4:07 PM
    except i needed that exact functionality 😄
  • d

    dkfdkdodkms

    05/16/2023, 4:08 PM
    until you find it's broken too 😉
  • a

    AA

    05/16/2023, 4:08 PM
    theres been a few misses, indeed
  • a

    AA

    05/16/2023, 4:09 PM
    tho slightly related to this, is there a way to force a worker to only execute in a certain area/region/country?
  • websocket client close casue worker throw error
    z

    zizi

    05/16/2023, 4:13 PM
    hi, it's seems if client close web socket and worker always throw the below error,
    Copy code
    text
    workerd/server/server.c++:2347: error: Uncaught exception: workerd/io/io-context.c++:1261: failed: remote.jsg.Error: The script will never generate a response.
    stack: 0 0 0 0 7ff71a146272 0 7ff71a146234 0 0 0
    workerd/server/server.c++:2259: error: exception = kj/compat/http.c++:2061: failed: expected !inBody; previous HTTP message body incomplete; can't write more messages
    stack: 7ff71a138a6f 7ff71a1d035d 7ff71a205121 7ff71a194056 7ff71a1941fb 7ff719fb2e64 7ff71a1b28ca 0 0
    An event handler returned a promise that will be ignored. Event handlers should not have a return value and should not be async functions.                                                                                        
    X [ERROR] Uncaught (in response) Error: The script will never generate a response.
    • 1
    • 2
  • d

    dave

    05/16/2023, 4:25 PM
    So all this does is set my secrets? https://developers.cloudflare.com/workers/learning/integrations/databases/#supabase cc @User (you mind like this too?)
  • j

    johnpyp

    05/16/2023, 4:59 PM
    https://blog.cloudflare.com/workers-tcp-socket-api-connect-databases/ I’m curious with the socket api, what happens if you store a global variable with a client/connection? I understand workers get evicted, but assuming the worker isn’t evicted for subsequent requests, would the TCP connection stay available? Or does cloudflare reset external io for every request?
  • c

    Chaika

    05/16/2023, 4:59 PM
    just can't https://developers.cloudflare.com/workers/runtime-apis/tcp-sockets/ "TCP sockets must be created within the fetch() handler of a Worker. TCP sockets cannot be created in global scope and shared across requests."
  • a

    AA

    05/16/2023, 5:00 PM
    no DO sockets 😛
  • a

    AA

    05/16/2023, 5:00 PM
    i just tested the pg connection using this new stuff. it works.
  • c

    Chaika

    05/16/2023, 5:00 PM
    I think "within the fetch handler" may not be true (ex, you should be able to use other handlers like scheduler/cron), but the rest about not being able to share it is
  • a

    AA

    05/16/2023, 5:01 PM
    now to figure out how to use cloudflared to expose a postgresdb only to my workers 😄
  • s

    Skye

    05/16/2023, 5:04 PM
    I believe DOs are the exception here - you can store it on
    this.state
    and reuse it fine
  • s

    sathoro

    05/16/2023, 5:13 PM
    Smart placement per route would be amazing (and is necessary for us to enable it because it would not make sense otherwise)
  • d

    dave

    05/16/2023, 5:16 PM
    100% agree with @sathoro. This is the one feature that would be very game changing for us. It would also be nice if we can do placements based on HTTP method and custom headers, but I understand that we probably have an unusual use-case and it won't be a priority.
  • u

    Unsmart | Tech debt

    05/16/2023, 5:17 PM
    Yeah its something I brought up too but doesnt seem likely from what I have heard
  • u

    Unsmart | Tech debt

    05/16/2023, 5:18 PM
    Best bet to achieve it is probably using many workers with worker routes instead of a single worker and the custom domain. Which can be pretty complicated of course 😅
  • d

    dkfdkdodkms

    05/16/2023, 5:18 PM
    my current workaround to ack being undefined on queue messages:
    Copy code
    if (message.ack !== undefined) message.ack(); //because cloudflare...
  • s

    sathoro

    05/16/2023, 5:31 PM
    you can also do
    message.ack?.()
    I learned this disgusting code from @Skye
  • s

    Skye

    05/16/2023, 5:32 PM
    You're welcome
  • u

    Unsmart | Tech debt

    05/16/2023, 5:34 PM
    or you could skip local and just test remotely
  • w

    Walshy | Pages

    05/16/2023, 5:34 PM
    of course it's from Skye
  • s

    Skye

    05/16/2023, 5:36 PM
    rude
  • s

    Skye

    05/16/2023, 5:36 PM
    I said it was cursed when I wrote it!
  • s

    sathoro

    05/16/2023, 5:37 PM
    yeah I would never write anything like that. I prefer something like this instead
    (message.ack ?? (() => {}))()
  • w

    Walshy | Pages

    05/16/2023, 5:37 PM
  • s

    sathoro

    05/16/2023, 5:38 PM
    it is clearly more self documenting and helps the reader understand what the author was intending
  • d

    dave

    05/16/2023, 5:39 PM
    yeah, eventually this will be what we do (split out backend auth stuff completely). But smart placement would be an easier solution.
  • s

    Skye

    05/16/2023, 5:40 PM
    We have passed this feedback on to the Smart Placement team in the past, hopefully it learns on an endpoint basis in future
1...246824692470...2509Latest