Skip to content

Commit dbd6bc3

Browse files
committed
fix: use uploadOne instead of awaiting each request
1 parent effcecb commit dbd6bc3

File tree

1 file changed

+5
-54
lines changed

1 file changed

+5
-54
lines changed

src/uploaders/NodeUploader.ts

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -197,60 +197,11 @@ export async function uploadMultiple ({
197197
return
198198
}
199199

200-
logger.debug(`Found ${sourceMaps.length} source map(s):`)
201-
logger.debug(` ${sourceMaps.join(', ')}`)
202-
203-
if (detectAppVersion) {
204-
try {
205-
appVersion = await _detectAppVersion(projectRoot, logger)
206-
} catch (e) {
207-
logger.error(e.message)
208-
throw e
209-
}
210-
}
211-
212-
let n = 0
213-
for (const sourceMap of sourceMaps) {
214-
n++
215-
logger.info(`${n} of ${sourceMaps.length}`)
216-
217-
const [ sourceMapContent, fullSourceMapPath ] = await readSourceMap(sourceMap, absoluteSearchPath, logger)
218-
const sourceMapJson = parseSourceMap(sourceMapContent, fullSourceMapPath, logger)
219-
220-
const bundlePath = sourceMap.replace(/\.map$/, '')
221-
let bundleContent, fullBundlePath
222-
try {
223-
[ bundleContent, fullBundlePath ] = await readBundleContent(bundlePath, absoluteSearchPath, sourceMap, logger)
224-
} catch (e) {
225-
// ignore error – it's already logged out
226-
}
227-
228-
const transformedSourceMap = await applyTransformations(fullSourceMapPath, sourceMapJson, projectRoot, logger)
229-
230-
logger.debug(`Initiating upload to "${url}"`)
231-
const start = new Date().getTime()
232-
try {
233-
await request(url, {
234-
type: PayloadType.Node,
235-
apiKey,
236-
appVersion,
237-
codeBundleId,
238-
minifiedUrl: path.relative(projectRoot, path.resolve(absoluteSearchPath, bundlePath)).replace(/\\/g, '/'),
239-
minifiedFile: (bundleContent && fullBundlePath) ? new File(fullBundlePath, bundleContent) : undefined,
240-
sourceMap: new File(fullSourceMapPath, JSON.stringify(transformedSourceMap)),
241-
overwrite: overwrite
242-
}, requestOpts, { idleTimeout })
200+
const promises = sourceMaps.map(async (sourceMap) => {
201+
uploadOne({apiKey, bundle: sourceMap.replace(/\.map$/, ''), sourceMap, appVersion, codeBundleId, overwrite, projectRoot, endpoint, detectAppVersion, requestOpts, logger, idleTimeout})
202+
})
243203

244-
const uploadedFiles = (bundleContent && fullBundlePath) ? `${sourceMap} and ${bundlePath}` : sourceMap
204+
await Promise.all(promises)
245205

246-
logger.success(`Success, uploaded ${uploadedFiles} to ${url} in ${(new Date()).getTime() - start}ms`)
247-
} catch (e) {
248-
if (e.cause) {
249-
logger.error(formatErrorLog(e), e, e.cause)
250-
} else {
251-
logger.error(formatErrorLog(e), e)
252-
}
253-
throw e
254-
}
255-
}
206+
return;
256207
}

0 commit comments

Comments
 (0)