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

    captain

    03/06/2023, 8:07 PM
    but i removed this line, not sure why it was there and things seem to function without issue
  • c

    captain

    03/06/2023, 8:08 PM
    but before it was working without issue, don't know if things got more strict. I had previously been set up as a service worker and then converted the whole project to module, so perhaps service worker was more forgiving
  • d

    dave

    03/06/2023, 8:12 PM
    I'm probably overthinking this, is there a way I can trigger a function once my Worker is done streaming a response?
  • f

    felixoi

    03/06/2023, 8:19 PM
    Someone has a quick tip how to combine Hono with a scheduler? Currently I just export default the hono instance
  • h

    HardAtWork

    03/06/2023, 8:41 PM
    I don’t think so
  • c

    Cyb3r-Jok3

    03/06/2023, 8:48 PM
    This is what I use
    Copy code
    typescript
    export default {
        async fetch(request: Request, env: Env, ctx: ExecutionContext) {
            return app.fetch(request, env, ctx)
        },
        async scheduled(_: ScheduledEvent, env: Env, ctx: ExecutionContext) {
            ctx.waitUntil(someFunction(env, ctx))
        },
    }
  • k

    kian

    03/06/2023, 9:06 PM
    fetch: app.fetch,
    should also work in the
    export default
    block
  • c

    Cyb3r-Jok3

    03/06/2023, 9:18 PM
    so it does. TIL
  • d

    Dani Foldi

    03/06/2023, 10:06 PM
    although that is a dangerous pattern in js, passing in
    ctx.waitUntil
    wouldn't work without
    .bind(context)
  • s

    Skye

    03/06/2023, 10:15 PM
    I assume you mean when you don't use Kian's version?
  • d

    Dani Foldi

    03/06/2023, 10:20 PM
    It's not the case for hono in either case I believe, context however loses this if you pass it without `.bind`ing it to context, so it just doesn't
    waitUntil
  • s

    Skye

    03/06/2023, 10:20 PM
    I thought that was only if you explicitly passed waitUntil as a method - instead of the entire context
  • s

    Skye

    03/06/2023, 10:21 PM
    Yeah, I just checked some code, passing around ctx is fine
  • d

    Dani Foldi

    03/06/2023, 10:21 PM
    yup, which is kinda the case if
    fetch
     wasn't the fetch of the worker, but something that needs a fetch method from an app
  • d

    Dani Foldi

    03/06/2023, 10:22 PM
    ah yeah that's entirely fine, the equivalent of that would be exporting hono directly in some way rather an instance method, such as fetch or indeed waitUntil
  • f

    felixoi

    03/06/2023, 10:35 PM
    I do not fully understand. Where do I need to add
    .bind
    ?
  • d

    Dani Foldi

    03/06/2023, 10:35 PM
    you should be all good without bind in this case 👍
  • d

    Dani Foldi

    03/06/2023, 10:35 PM
    sorry if my comment caused confusion 😄
  • f

    felixoi

    03/06/2023, 10:35 PM
    Ah k, no problem
  • p

    Pato

    03/06/2023, 11:12 PM
    does someone know if workers suppor this library
    const crypto = require('crypto');
  • s

    Skye

    03/06/2023, 11:15 PM
    answered in a thread
  • p

    Pato

    03/06/2023, 11:37 PM
    Anyone that has used web crypto that can helpme translate this code snippet
    Copy code
    js
    getSign() {
            var sign = crypto.createSign('RSA-SHA256');
            sign.update(this.cadenaOriginal);
            sign.end();
            const key = fs.readFileSync('ssl/key.pem');
            let signature_b64 = sign.sign(key, 'base64');
            return signature_b64;
        }
  • p

    Pato

    03/06/2023, 11:39 PM
    or using CryptoJs
  • z

    zszszsz

    03/07/2023, 12:06 AM
    Can it be async
  • l

    lattenb

    03/07/2023, 12:17 AM
    @Ceru © any quick feedback on this coding question? banging my head on trying to get a custom webpack build going https://discord.com/channels/595317990191398933/846453104382836766/1082413032732381204
  • c

    Ceru ©

    03/07/2023, 12:20 AM
    how are you testing this? miniflare or using wrangler dev
  • l

    lattenb

    03/07/2023, 12:20 AM
    wrangler dev
  • c

    Ceru ©

    03/07/2023, 12:21 AM
    as far as i can recall
    { default: fetch }
    isnt how its detected
  • c

    Ceru ©

    03/07/2023, 12:21 AM
    it needs to be exported as a module
  • l

    lattenb

    03/07/2023, 12:22 AM
    i believe i've tried all possible output styles from commonjs --> module. but let me do that one specifically
1...232423252326...2509Latest