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

    bulk88

    05/24/2023, 9:30 PM
    that would be a major bug or is it a feature....
  • b

    bulk88

    05/24/2023, 9:34 PM
    this is a bug
  • b

    bulk88

    05/24/2023, 9:34 PM
    gRPC Allow gRPC connections to your origin server. Learn more. WebSockets Allow WebSockets connections to your origin server. Concurrent connection guidelines for your plan: low. Learn more. This setting was last changed a few seconds ago
  • b

    bulk88

    05/24/2023, 9:35 PM
    If I turn off gRPC and WebSockets dash toggles, for my custom domain, CFW quick edit, dev tools crashes
  • s

    ScarabCoder

    05/24/2023, 9:55 PM
    Is it possible to use an HTTP proxy server when making outbound fetch calls from a Worker? I have some external services that are IP-restricted, and since CF Worker IPs aren't static I need to proxy it through another server (via tunneling) to make the call.
  • l

    lastguru

    05/24/2023, 10:01 PM
    I have done that. I need to fetch from a non-standard https port. Nginx proxy works flawlessly. Not very convenient though, as it introduces more moving parts, that can fail…
  • l

    lastguru

    05/24/2023, 10:02 PM
    I am hoping, that Cloudflare will allow fetch requests to non-standard ports someday…
  • s

    ScarabCoder

    05/24/2023, 10:03 PM
    Ah, gotcha, so you just made requests directly to the nginx reverse proxy?
  • l

    lastguru

    05/24/2023, 10:03 PM
    Yes
  • s

    ScarabCoder

    05/24/2023, 10:04 PM
    Thanks, seems like that'll end up being the lightest solution
  • s

    silentdevnull

    05/24/2023, 10:29 PM
    Does that example work for you. I copy it and trying to run it to see it work and it giving me errror
    Copy code
    ✘ [ERROR] Expected ")" but found ":"
    
        src/index.js:4:23:
          4 │     async fetch(request: Request, env: Env): Promise<Response> {
            │                        ^
            ╵                        )
    
    
    ✘ [ERROR] Expected ")" but found ":"
    
        src/index.js:4:23:
          4 │     async fetch(request: Request, env: Env): Promise<Response> {
            │                        ^
            ╵                        )
    So before I try anything wanted to see if it worked for your or someone else.
  • w

    Walshy | Pages

    05/24/2023, 10:29 PM
    looks like you're using JavaScript not TypeScript
  • w

    Walshy | Pages

    05/24/2023, 10:29 PM
    if you remove the typing, it should work
  • s

    silentdevnull

    05/24/2023, 10:37 PM
    It is javascript. I just recreated it with the typescript option and it doesn't like fetch still.
  • s

    silentdevnull

    05/24/2023, 10:38 PM
    Copy code
    Cannot read properties of undefined (reading 'fetch')
  • w

    Walshy | Pages

    05/24/2023, 10:42 PM
    what's your full code?
  • s

    silentdevnull

    05/24/2023, 10:51 PM
    I just copied the example as it looked complete.
    Copy code
    import puppeteer from "@cloudflare/puppeteer";
    
    export default {
        async fetch(request: Request, env: Env): Promise<Response> {
            const browser = await puppeteer.launch(env.MYBROWSER);
            const page = await browser.newPage();
            await page.goto("https://example.com");
            const metrics = await page.metrics();
            await browser.close();
            return new Response(JSON.stringify(metrics));
        },
    };
  • c

    Chaika

    05/24/2023, 10:54 PM
    iirc you're missing node_compat? Or browser isn't set? I got that same error when I was setting this up yesterday, and it was fixed by me copying their wrangler.toml, can't remember if it was node_compat specifically or something else though. If you don't have it set at all though, you should
  • c

    Chaika

    05/24/2023, 10:55 PM
    your wrangler.toml should be like:
    Copy code
    name = "browser-worker"
    main = "src/index.ts"
    compatibility_date = "2023-03-14"
    node_compat = true
    workers_dev = true
    
    browser = { binding = "MYBROWSER", type = "browser" }
    Make sure you're not trying to test locally as well. If you're on the latest wrangler/wrangler@3, use
    npx wrangler dev --remote
  • w

    Walshy | Pages

    05/24/2023, 11:09 PM
    yeah seems like MYBROWSER isn't defined as a browser binding
  • s

    silentdevnull

    05/24/2023, 11:25 PM
    this what I have in wrangler.toml name = "testcf" main = "src/index.ts" compatibility_date = "2023-05-24" node_compat = true workers_dev = true browser = { binding = "MYBROWSER", type = "browser" } Warning on publishing
    Copy code
    ⛅️ wrangler 2.19.0 (update available 3.0.1)
    ------------------------------------------------------
    ▲ [WARNING] Processing wrangler.toml configuration:
    
        - Unexpected fields found in top-level field: "browser"
    
    
    ▲ [WARNING] Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details.
    Error when I publish it is 1101. I haven't moved to version 3 of wrangler as the command changed so I need to have a minute to figure it out
  • w

    Walshy | Pages

    05/24/2023, 11:26 PM
    aww man... you do need 3.0
  • w

    Walshy | Pages

    05/24/2023, 11:27 PM
    you can use unsafe for now
    Copy code
    toml
    [[unsafe.bindings]]
    binding = "MYBROWSER"
    type = "browser"
  • s

    silentdevnull

    05/24/2023, 11:37 PM
    I'm planning on moving to 3.0. The create command works doesn't much how I like to layout my directories and in my editors. So I just need to figure out how I want to make it work. The way I do thing now is create git repo or using existing one. Then I would clone it down and then cd to that directory and do the init command it would create everything. Now it create a directory with everything in it. So I just need to do some playing.
  • s

    silentdevnull

    05/25/2023, 12:09 AM
    after work tomorrow I will upgrade to 3.0 and give it another try
  • u

    柴柴

    05/25/2023, 6:26 AM
    I write fetch together with tail but tail doesn't work
  • u

    柴柴

    05/25/2023, 6:28 AM
    I tried specifying myself in
    wrangler.toml
    but it won't work either
  • u

    柴柴

    05/25/2023, 6:33 AM
    Copy code
    ts
    export default <ExportedHandler<Env>> {
        async fetch(req, env, ctx) {
            ...
        },
    
        async tail(events, env) {
            for (const event of events) {
                if (!(event.event as TraceItemFetchEventInfo).request) continue;
                await env.BUCKET.put(
                    '',
                    JSON.stringify(event),
                    { httpMetadata: { contentType: 'application/json' } }
                );
            }
        },
    
        async scheduled(event, env, ctx) {
            ...
        }
    };
  • n

    Neiki

    05/25/2023, 7:20 AM
    i also have an error with tail workers: https://discord.com/channels/595317990191398933/1111191921495380018
  • n

    Neiki

    05/25/2023, 7:32 AM
    its not working https://discord.com/channels/595317990191398933/1111191921495380018/1111191921495380018
1...249324942495...2509Latest