apache/beam · info

Downloading

Error message

Downloading

What it means

The TypeScript Beam worker's cachedJar helper logs 'Downloading <url>' via console.warn when it starts fetching a jar/artifact over HTTPS to cache it locally. It is informational (logged at warn level); a non-200 status afterwards rejects with 'Error code ... when downloading'.

Solutions

  1. Pre-download or pre-stage the artifact at the expected cache path so the download step is skipped.
  2. If downloads fail after this line, check the artifact URL, proxy settings, and network egress from the worker.
  3. If the log is noise, ensure artifacts are provided via the environment's artifact service or local paths instead of https URLs.

Example fix

// before
const url = "https://example.com/lib.jar"; // downloaded at runtime
// after
const path = "/opt/artifacts/lib.jar"; // pre-staged, no download
await cachedJar(path);
Defensive patterns

Strategy: fallback

Validate before calling

import fs from 'fs';
const cachePath = cachePathFor(urlOrPath);
if (fs.existsSync(cachePath)) {
  console.log(`Using cached artifact ${cachePath}, no download needed`);
}

Try / catch

try {
  const jar = await cachedJar(urlOrPath);
} catch (e) {
  console.error(`Artifact download failed: ${e}; ensure egress or pre-stage the jar`);
  throw e;
}

Prevention

When it happens

Trigger: First resolution of a remote artifact URL (urlOrPath is an https URL) in the Fn Harness artifact/cache path, when the jar is not already cached at dest.

Common situations: Running Beam TypeScript pipelines in environments where dependencies must be downloaded at runtime; slow or proxied networks making this line appear frequently; misconfigured artifact service causing subsequent download failures.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/055cbd3d3dacd1b3. Report an issue: GitHub.

Appendix: source

Thrown at sdks/typescript/src/apache_beam/utils/service.ts:262

  static async cachedJar(
    urlOrPath: string,
    cacheDir: string = JavaJarService.JAR_CACHE,
  ): Promise<string> {
    if (urlOrPath.match(/^https?:\/\//)) {
      fs.mkdirSync(cacheDir, { recursive: true });
      const dest = path.join(
        JavaJarService.JAR_CACHE,
        path.basename(urlOrPath),
      );
      if (fs.existsSync(dest)) {
        return dest;
      }
      // TODO: (Cleanup) Use true temporary file.
      const tmp = dest + ".tmp" + Math.random();
      return new Promise((resolve, reject) => {
        const fout = fs.createWriteStream(tmp);
        console.warn("Downloading", urlOrPath);
        const request = https.get(urlOrPath, function (response) {
          if (response.statusCode !== 200) {
            reject(
              `Error code ${response.statusCode} when downloading ${urlOrPath}`,
            );
          }
          response.pipe(fout);
          fout.on("finish", function () {
            fout.close(() => {
              fs.renameSync(tmp, dest);
              resolve(dest);
            });
          });
        });
      });
    } else {
      return urlOrPath;
    }

View on GitHub (pinned to 12126d8942)