Error logs in Pages/Functions

Is there any way in Pages/Functions to see error logs? If I have code that runs fine under wrangler pages dev but throws an exception on the actual server, how would I see what’s going on?

The Error 1101 page suggests that I “should login to Cloudflare and check the error logs”, but I can’t find a way to do any such thing.

Unfortunately not today. It’s coming soon, but for now the only real option is to wrap functions with try…catch and pipe the errors off to something external like Sentry, Honeycomb, etc.

If you share the code that’s working locally and not in prod, we might be able to spot something. Some of the most common errors are responses that are mutable in local dev but immutable in prod and need to be cloned.

Right, so, I’m trying to use this library for SVG->PNG conversion, and I’ve never used WebAssembly before, and the documentation is sparse, so my assumption is that I’m doing something boneheadedly dumb that would be immediately apparent if I saw the error logs. I’m not sure I completely understand how wasm is supposed to be loaded.

But this is reduced to the barest minimum, works locally, and errors when deployed.

import { initialize, svg2png } from 'svg2png-wasm';

const svgtext = `<svg version="1.1" xmlns="http://www.w3.org/2000/svg" height="100" width="100"><circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /></svg>`;

export async function onRequest(context) {
    const { request, env, params, waitUntil, next, data } = context;

    const u = new URL(request.url);
    const wreq = new Request(new URL(`${ u.protocol }//${ u.host }/lib/svg2png_wasm_bg.wasm`));
    await initialize(fetch(wreq))

    const png = await svg2png(svgtext, {});

    return new Response(png, {
        headers: {
            'content-type': 'image/png'
        }
    });
}

I do not believe Functions supports wasm yet unfortunately

1 Like

Well, that would certainly answer the question. :man_facepalming:t2:

1 Like

Minimal example works as a Worker, so yeah, that’s it. :confused:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.