{"record":{"id":"bca8334bfab286e0","repo":"usebruno/bruno","slug":"result-error-bca833","errorCode":null,"errorMessage":"${result.error}","messagePattern":"\\$\\{result\\.error\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-converters/src/workers/postman-translator-worker.js","lineNumber":160,"sourceCode":"}\n\nconst scriptTranslationWorker = async (scriptMap) => {\n  // Convert the Map to an array of entries\n  const scriptEntries = Array.from(scriptMap.entries());\n  const maxWorkers = getMaxWorkers();\n\n  // For very small collections, don't parallelize\n  if (scriptEntries.length <= 50) {\n    const workerPool = new WorkerPool(path.join(__dirname, './src/workers/scripts/translate-postman-scripts.js'), 1);\n    workerPool.initialize();\n\n    try {\n      const translatedScripts = new Map();\n      const result = await workerPool.runTask({ scripts: scriptEntries });\n\n      if (result.error) {\n        console.error('Error in script translation worker:', result.error);\n        throw new Error(result.error);\n      }\n\n      result.forEach(([uid, { request }]) => {\n        translatedScripts.set(uid, { request });\n      });\n\n      return translatedScripts;\n    } finally {\n      workerPool.terminate();\n    }\n  }\n\n  const workerCount = Math.min(maxWorkers, 4);\n\n  // Create balanced batches based on script complexity\n  const batches = createBalancedBatches(scriptEntries, workerCount);\n\n  const translatedScripts = new Map();","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-converters/src/workers/postman-translator-worker.js#L142-L178","documentation":"Thrown by scriptTranslationWorker (the <=50 scripts path) when the worker pool's runTask resolves with a result object carrying an `error` field. The worker script (translate-postman-scripts.js) returns { error } instead of throwing when it catches an internal failure, so this throw converts that sentinel into a real exception. The original error text is the value of result.error.","triggerScenarios":"A Postman pre-request or test script that the translate-postman-scripts worker cannot parse/translate, causing the worker to populate result.error. Triggers only when the collection has <=50 script entries (the small-collection path).","commonSituations":"Scripts using Postman sandbox APIs the translator does not support (pm.sendRequest callbacks, complex pm.expect chains, syntax errors in the script, unsupported pm.require targets).","solutions":["Inspect stderr — `console.error('Error in script translation worker:', result.error)` on line 159 prints the worker's error detail.","Import with `{ preserveScripts: true }` to skip translation entirely and keep raw scripts.","Simplify or fix the offending Postman script, then re-import."],"exampleFix":"// before\nconst translated = await scriptTranslationWorker(map);\n\n// after — skip translation on failure\ntry {\n  return await scriptTranslationWorker(map);\n} catch (e) {\n  console.warn('script translation failed, falling back', e.message);\n  return map; // return un-translated entries\n}","handlingStrategy":"fallback","validationCode":"const hasTranslatableScripts = (map) => {\n  for (const [, entry] of map) {\n    if (entry?.request?.tests || entry?.request?.preRequest) return true;\n  }\n  return false;\n};","typeGuard":null,"tryCatchPattern":"try {\n  return await scriptTranslationWorker(map);\n} catch (e) {\n  console.warn('script translation failed, keeping originals:', e.message);\n  return map; // fallback: return un-translated entries\n}","preventionTips":["Import with preserveScripts:true if you do not need script translation.","Simplify Postman scripts (avoid unsupported pm.* APIs) before import.","Capture stderr to identify which script the worker choked on."],"tags":["postman","worker","script-translation","bruno-converters","parallel"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}