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

    Walshy | Pages

    04/12/2023, 8:14 PM
    @Skye know of any weirdness with D1's shim taking a ton of CPU time? The operations it does isn't complex. Perhaps the JSON parse from the SQL response?
  • w

    Walshy | Pages

    04/12/2023, 8:14 PM
    (God I can't wait to get rid of this shim)
  • s

    Skye

    04/12/2023, 8:15 PM
    I mean the only high cpu thing would be parsing a big json blob
  • w

    Walshy | Pages

    04/12/2023, 8:16 PM
    Yeah that's what I'm thinking... I hate that this manifests for users due to the shim
  • s

    Skye

    04/12/2023, 8:16 PM
    I mean, wouldn't that happen for native bindings too?
  • w

    Walshy | Pages

    04/12/2023, 8:17 PM
    I don't think we count binding compute time
  • w

    Walshy | Pages

    04/12/2023, 8:17 PM
    (Also ideally we don't use JSON for the real binding)
  • s

    Skye

    04/12/2023, 8:18 PM
    I'd love to see how that works when I have a gchat
  • w

    Walshy | Pages

    04/12/2023, 8:18 PM
    Don't think you want to read C++
  • w

    Walshy | Pages

    04/12/2023, 8:18 PM
    It's not easy to parse
  • s

    Skye

    04/12/2023, 8:18 PM
    true, ew
  • s

    Skye

    04/12/2023, 8:18 PM
    almost as unreadable as rust
  • w

    Walshy | Pages

    04/12/2023, 8:19 PM
    Sadly it's far far worse
  • m

    Mozzy

    04/12/2023, 8:20 PM
    In short, I can't do anything to bring the CPU time down on my side?
  • h

    HardAtWork

    04/12/2023, 8:26 PM
    Laughs in Cereal
  • t

    Tarnadas

    04/12/2023, 8:27 PM
    Hey, I'm trying to set up postgres, but I'm just accessing a public db so I don't want to set up tunneling. Is it possible to do this? I tried following this (https://developers.cloudflare.com/workers/tutorials/query-postgres-from-workers-using-database-connectors/), but when I fetch my API and it tries to connect to postgres I receive:
    Copy code
    (log) Fetch API cannot load: mainnet.db.explorer.indexer.near.dev
    my client connection looks like this:
    Copy code
    ts
          const client = new Client({
            user: 'public_readonly',
            password: 'nearprotocol',
            database: 'mainnet_explorer',
            hostname: 'mainnet.db.explorer.indexer.near.dev',
            port: '5432',
          })
  • h

    HardAtWork

    04/12/2023, 8:29 PM
    The database connector connects to a WebSocket, which would be provided by the Tunnel. If you are connecting to a public DB that doesn't provide a WebSocket API, then it will not work.
  • t

    Tarnadas

    04/12/2023, 8:30 PM
    Are there any other libraries I could use instead, so that I don't need the tunnel?
  • t

    Tarnadas

    04/12/2023, 8:32 PM
    Will go to sleep now so checking back later
  • h

    HardAtWork

    04/12/2023, 8:33 PM
    No. At the moment, unless you have access to the TCP Worker beta, then you cannot connect to anything that doesn't support HTTP(S) or WebSockets, whether that be a Database, a Live Stream, or something else.
  • h

    HardAtWork

    04/12/2023, 8:34 PM
    Note too that directly opening a connection to your DB in a Worker may not be the best approach anyway, as most databases are not optimized for extremely short-lived connections running only 1-2 queries.
  • w

    Wichard

    04/12/2023, 9:46 PM
    Hi, I am very confused, I have made a websocket server which allows connections from any IPv4, and I am trying to use a worker as a proxy for a client. I can successfully to the server from a local client, but when connecting through the proxy I am getting a 403 Error
  • w

    Wichard

    04/12/2023, 9:48 PM
    This is the response that the worker gets when trying to connect to the server:
    Copy code
    Response { body: Stream(ReadableStream { obj: Object { obj: JsValue(Object({"locked":false})) } }), headers: Headers {
    cache-control = private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    cf-connection-close = close
    cf-ray = 7b6e9f69a2e34141-LHR
    connection = keep-alive
    content-length = 16
    content-type = text/plain; charset=UTF-8
    date = Wed, 12 Apr 2023 21:39:34 GMT
    expires = Thu, 01 Jan 1970 00:00:01 GMT
    referrer-policy = same-origin
    server = cloudflare
    x-frame-options = SAMEORIGIN
    }
    , status_code: 403, websocket: None }
  • w

    Wichard

    04/12/2023, 9:50 PM
    The weird thing is that this proxy thing is working well when connecting to an external server, but not to the barebone server I have just created for testing, which suggests to tweak something in the server side?
  • j

    Jorge Murta

    04/12/2023, 9:54 PM
    Does anyone know if it is possible to run workers on only one region?
  • c

    Cyb3r-Jok3

    04/12/2023, 9:56 PM
    Not without being enterprise. You can just make a firewall that blocks access to the worker apart from certain areas depending on your needs
  • j

    Jorge Murta

    04/12/2023, 10:08 PM
    Thank you so much for your quick response, that’s what I though, sad to hear.
  • e

    embed

    04/12/2023, 10:27 PM
    If I need to cache posts a user loads from the db should I be using workers kv for this?
  • s

    silence

    04/13/2023, 1:03 AM
    Does anyone host a discord bot on pages/functions? If so could you tell me do you use a scheduledfetchevent to update your commands and intent or is there a better way to do it
  • c

    Cyb3r-Jok3

    04/13/2023, 1:08 AM
    You should probably do it during the deployment process
1...239023912392...2509Latest