Yes, this crashes with `"wrangler": "3.78.10"`, but works fine with wrangler on `3.78.9`: ```js fun

Yes, this crashes with "wrangler": "3.78.10", but works fine with wrangler on 3.78.9:

function isNotEmptyObject<T extends Record<string, any>>(val: T | unknown): val is T {
    if (Object.prototype.toString.call(val) !== '[object Object]') return false;
    for (const _ in val as Record<string, any>) {
        return true;
    }
    return false;
}

export default {
    async fetch(request, env, ctx): Promise<Response> {
        if (!isNotEmptyObject(ctx)) throw new Error('ctx');
        return new Response('Hello World!');
    },
} satisfies ExportedHandler<Env>;


We think this might be the commit that caused the behaviour change: https://github.com/cloudflare/workerd/pull/2801/files

I assume impact will be low though, pretty niche to do this check on ctx
Was this page helpful?