{"record":{"id":"919f59f791337baa","repo":"usebruno/bruno","slug":"err","errorCode":null,"errorMessage":"${err}","messagePattern":"\\$\\{err\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-converters/src/workers/postman-translator-worker.js","lineNumber":194,"sourceCode":"  const batches = createBalancedBatches(scriptEntries, workerCount);\n\n  const translatedScripts = new Map();\n\n  // Create worker pool with optimal size\n  const workerPool = new WorkerPool(path.join(__dirname, './src/workers/scripts/translate-postman-scripts.js'), workerCount);\n  workerPool.initialize();\n\n  // Process all batches in parallel using worker pool\n  const batchPromises = batches.map((batch) => {\n    return workerPool.runTask({ scripts: batch })\n      .then((modScripts) => {\n        modScripts.forEach(([name, { request }]) => {\n          translatedScripts.set(name, { request });\n        });\n      })\n      .catch((err) => {\n        console.error('Error in script translation worker:', err);\n        throw new Error(err);\n      });\n  });\n\n  // Wait for all batches to complete\n  try {\n    await Promise.allSettled(batchPromises);\n  } finally {\n    // Clean up worker pool\n    workerPool.terminate();\n  }\n\n  return translatedScripts;\n};\n\nexport default scriptTranslationWorker;\n","sourceCodeStart":176,"sourceCodeEnd":210,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-converters/src/workers/postman-translator-worker.js#L176-L210","documentation":"Thrown by the batched (>50 scripts) path of scriptTranslationWorker when a worker pool task rejects. The catch wraps the rejection in `new Error(err)`, where err may itself be an Error or a plain value — `new Error(err)` coerces it to a string message. This path differs from error 127: it uses Promise.allSettled over parallel batches, so one failing batch fails the whole translation.","triggerScenarios":"Any worker.runTask rejection during parallel batch translation of Postman scripts (collections with >50 script entries). The same root causes as error 127, but on the large-collection code path.","commonSituations":"Large Postman collections where one script among many is untranslatable; worker thread crash/OOM; the translate-postman-scripts worker throwing on a specific pm.* API.","solutions":["Read stderr from line 193 (`console.error('Error in script translation worker:', err)`) to find which batch/script failed.","Note that Promise.allSettled is used but the catch rethrows — a single batch failure aborts all; consider importing with preserveScripts to bypass.","Reduce collection size or split imports to locate the offending script."],"exampleFix":"// before (worker catch)\n.catch((err) => {\n  console.error('worker err', err);\n  throw new Error(err);\n});\n\n// after — preserve Error chain\n.catch((err) => {\n  console.error('worker err', err);\n  throw err instanceof Error ? err : new Error(String(err));\n});","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await scriptTranslationWorker(map);\n} catch (e) {\n  throw e instanceof Error ? e : new Error(String(e));\n}","preventionTips":["Note: a single failing batch aborts all batches — split large collections to find the offender.","Use preserveScripts:true as a bypass when translation keeps failing.","Inspect stderr from line 193 to see the batch-level error."],"tags":["postman","worker","script-translation","bruno-converters","parallel","promise"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}