Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Invalid URL #661

Open
fa0311 opened this issue Feb 18, 2025 · 0 comments
Open

TypeError: Invalid URL #661

fa0311 opened this issue Feb 18, 2025 · 0 comments

Comments

@fa0311
Copy link

fa0311 commented Feb 18, 2025

Bug report

Description / Observed Behavior

When importing the @vercel/og module, an error occurs during the module's initialization in a GitHub Actions environment. The error appears to be related to converting a file path to a URL for the bundled font file (noto-sans-v27-latin-regular.ttf). This issue does not occur on my Japanese Windows machine but consistently reproduces on GitHub Actions using various Node.js versions (e.g., lts/-1, lts/*, latest).

The error log includes the following message:

TypeError: Invalid URL
    at new URL (node:internal/url:806:29)
    at fileURLToPath (node:internal/url:1485:12)
    at file:///D:/a/satiri-test/satiri-test/node_modules/@vercel/og/dist/index.node.js:18929:32
    ...
    input: '.\\file:\\D:\\a\\satiri-test\\satiri-test\\node_modules\\@vercel/og\\dist\\noto-sans-v27-latin-regular.ttf'

Expected Behavior

I expect @vercel/og to correctly resolve and load its assets (like fonts) without errors, regardless of the environment. The module should work seamlessly both locally and in CI environments such as GitHub Actions.

Reproduction

The issue can be reproduced with the following code:

import fs from "node:fs/promises";
import { ImageResponse } from "@vercel/og";
import component from "./component";

(async () => {
  const response = new ImageResponse(component(), {
    width: 800,
    height: 600,
  });
  await fs.writeFile("out.png", Buffer.from(await response.arrayBuffer()));
})();

To reproduce:

  1. Clone the repository: https://github.com/fa0311/satori-test
  2. Run the code with:
    node --loader ts-node/esm src/main.ts

or

  1. Observe the error in the GitHub Actions logs: GitHub Actions Run

Additional Context

  • @vercel/og version: 0.6.5
  • React version: 19.0.0
  • Node.js version: Tested with v20.18.2 and others
  • Environment: The issue occurs in GitHub Actions (CI), while it does not on my local Japanese Windows environment.
  • Additional Note: There is an experimental warning related to the --experimental-loader flag, and the error seems to be triggered during the import stage when resolving the font file URL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant