{"record":{"id":"055cbd3d3dacd1b3","repo":"apache/beam","slug":"downloading","errorCode":null,"errorMessage":"Downloading","messagePattern":"Downloading","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"sdks/typescript/src/apache_beam/utils/service.ts","lineNumber":262,"sourceCode":"\n  static async cachedJar(\n    urlOrPath: string,\n    cacheDir: string = JavaJarService.JAR_CACHE,\n  ): Promise<string> {\n    if (urlOrPath.match(/^https?:\\/\\//)) {\n      fs.mkdirSync(cacheDir, { recursive: true });\n      const dest = path.join(\n        JavaJarService.JAR_CACHE,\n        path.basename(urlOrPath),\n      );\n      if (fs.existsSync(dest)) {\n        return dest;\n      }\n      // TODO: (Cleanup) Use true temporary file.\n      const tmp = dest + \".tmp\" + Math.random();\n      return new Promise((resolve, reject) => {\n        const fout = fs.createWriteStream(tmp);\n        console.warn(\"Downloading\", urlOrPath);\n        const request = https.get(urlOrPath, function (response) {\n          if (response.statusCode !== 200) {\n            reject(\n              `Error code ${response.statusCode} when downloading ${urlOrPath}`,\n            );\n          }\n          response.pipe(fout);\n          fout.on(\"finish\", function () {\n            fout.close(() => {\n              fs.renameSync(tmp, dest);\n              resolve(dest);\n            });\n          });\n        });\n      });\n    } else {\n      return urlOrPath;\n    }","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/typescript/src/apache_beam/utils/service.ts#L244-L280","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pre-download or pre-stage the artifact at the expected cache path so the download step is skipped.","If downloads fail after this line, check the artifact URL, proxy settings, and network egress from the worker.","If the log is noise, ensure artifacts are provided via the environment's artifact service or local paths instead of https URLs."],"exampleFix":"// before\nconst url = \"https://example.com/lib.jar\"; // downloaded at runtime\n// after\nconst path = \"/opt/artifacts/lib.jar\"; // pre-staged, no download\nawait cachedJar(path);","handlingStrategy":"fallback","validationCode":"import fs from 'fs';\nconst cachePath = cachePathFor(urlOrPath);\nif (fs.existsSync(cachePath)) {\n  console.log(`Using cached artifact ${cachePath}, no download needed`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const jar = await cachedJar(urlOrPath);\n} catch (e) {\n  console.error(`Artifact download failed: ${e}; ensure egress or pre-stage the jar`);\n  throw e;\n}","preventionTips":["Pre-stage jars via the artifact service or local paths to avoid runtime downloads","Configure proxy/egress so https artifact fetches succeed","Monitor for the follow-up 'Error code NNN when downloading' rejections"],"tags":["typescript","download","network","logging"],"backgroundTag":"artifact-download-failure","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}