kvnang/workers-og

Exception "The script will never generate a response" in Remix but not a "vanilla" worker

Opened this issue · 0 comments

Hello, I'm getting this strange error from Miniflare when using Remix (classic compiler, template here, not Vite).

This is my entire loader (I just want to generate a small transparent image):

// route: routes/image.$width[.]png.ts
// visit url: /image/400.png
export const loader = async ({ request, params }: LoaderArgs) => {
  const { width } = zxParseParams(params, {
    width: zx.IntAsString.refine((v) => v >= 300 && v <= 400),
  });

  return new ImageResponse(`<div style="display:none"></div>`, {
    width,
    height: 1,
    format: "png",
  });
};

This works fine in a brand new worker with no framework installed, however:

export default {
  async fetch(request, env, ctx): Promise<Response> {
    return new ImageResponse(`<div style="display:none"></div>`, {
      width: 400,
      height: 1,
      format: "png",
    });
  },
}

You might think this is to do with some middleware from the Remix server, but I don't think so, as this also happens if you uproot everything in server.ts and replace it with the above "vanilla" code. What's going on? All I can glean from the error is that a promise is hanging and Miniflare has detected that, but I'm not sure how to prove/resolve that. Any help is greatly appreciated!