@bugsnag/source-maps
Advanced tools
Comparing version 2.2.0 to 2.3.0
# Changelog | ||
## 2.3.0 (2021-08-05) | ||
- Add `--idle-timeout` flag to control the HTTP request timeout ([see Node documentation](https://nodejs.org/api/http.html#http_request_settimeout_timeout_callback)) [#74](https://github.com/bugsnag/bugsnag-source-maps/pull/74) | ||
- Increase the default HTTP request timeout to 10 minutes (from 5 minutes) [#74](https://github.com/bugsnag/bugsnag-source-maps/pull/74) | ||
## 2.2.0 (2021-07-05) | ||
@@ -4,0 +9,0 @@ |
@@ -13,2 +13,6 @@ export declare const commonCommandDefs: ({ | ||
description?: undefined; | ||
} | { | ||
name: string; | ||
type: NumberConstructor; | ||
description: string; | ||
})[]; |
@@ -11,4 +11,5 @@ "use strict"; | ||
{ name: 'quiet', type: Boolean, description: 'less verbose logging' }, | ||
{ name: 'code-bundle-id', type: String } | ||
{ name: 'code-bundle-id', type: String }, | ||
{ name: 'idle-timeout', type: Number, description: 'idle timeout for HTTP requests in minutes' } | ||
]; | ||
//# sourceMappingURL=CommandDefinitions.js.map |
@@ -88,2 +88,3 @@ "use strict"; | ||
codeBundleId: browserOpts.codeBundleId, | ||
idleTimeout: browserOpts.idleTimeout, | ||
logger: Logger_1.default | ||
@@ -104,2 +105,3 @@ }); | ||
codeBundleId: browserOpts.codeBundleId, | ||
idleTimeout: browserOpts.idleTimeout, | ||
logger: Logger_1.default | ||
@@ -106,0 +108,0 @@ }); |
@@ -81,2 +81,3 @@ "use strict"; | ||
codeBundleId: nodeOpts.codeBundleId, | ||
idleTimeout: nodeOpts.idleTimeout, | ||
logger: Logger_1.default | ||
@@ -96,2 +97,3 @@ }); | ||
codeBundleId: nodeOpts.codeBundleId, | ||
idleTimeout: nodeOpts.idleTimeout, | ||
logger: Logger_1.default | ||
@@ -98,0 +100,0 @@ }); |
@@ -66,2 +66,3 @@ "use strict"; | ||
bundlerEntryPoint: reactNativeOpts.bundlerEntryPoint, | ||
idleTimeout: reactNativeOpts.idleTimeout, | ||
logger: Logger_1.default | ||
@@ -84,2 +85,3 @@ }); | ||
endpoint: reactNativeOpts.endpoint, | ||
idleTimeout: reactNativeOpts.idleTimeout, | ||
logger: Logger_1.default | ||
@@ -86,0 +88,0 @@ }); |
@@ -35,6 +35,9 @@ /// <reference types="node" /> | ||
} | ||
export default function request(endpoint: string, payload: Payload, requestOpts: http.RequestOptions): Promise<void>; | ||
export declare function send(endpoint: string, payload: Payload, requestOpts: http.RequestOptions): Promise<void>; | ||
interface RequestOptions { | ||
idleTimeout?: number; | ||
} | ||
export default function request(endpoint: string, payload: Payload, requestOpts: http.RequestOptions, options?: RequestOptions): Promise<void>; | ||
export declare function send(endpoint: string, payload: Payload, requestOpts: http.RequestOptions, options?: RequestOptions): Promise<void>; | ||
export declare function isRetryable(status?: number): boolean; | ||
export declare function fetch(endpoint: string): Promise<string>; | ||
export declare function fetch(endpoint: string, options?: RequestOptions): Promise<string>; | ||
export {}; |
@@ -24,4 +24,4 @@ "use strict"; | ||
const RETRY_INTERVAL_MS = parseInt(process.env.BUGSNAG_RETRY_INTERVAL_MS) || 1000; | ||
const TIMEOUT_MS = parseInt(process.env.BUGSNAG_TIMEOUT_MS) || 30000; | ||
function request(endpoint, payload, requestOpts) { | ||
const DEFAULT_TIMEOUT_MS = parseInt(process.env.BUGSNAG_TIMEOUT_MS) || 60000; | ||
function request(endpoint, payload, requestOpts, options = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -32,3 +32,3 @@ let attempts = 0; | ||
attempts++; | ||
yield send(endpoint, payload, requestOpts); | ||
yield send(endpoint, payload, requestOpts, options); | ||
} | ||
@@ -91,3 +91,3 @@ catch (err) { | ||
} | ||
function send(endpoint, payload, requestOpts) { | ||
function send(endpoint, payload, requestOpts, options = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -136,3 +136,3 @@ return new Promise((resolve, reject) => { | ||
addErrorHandler(req, reject); | ||
addTimeout(req, reject); | ||
addTimeout(req, reject, options); | ||
}); | ||
@@ -151,3 +151,3 @@ }); | ||
exports.isRetryable = isRetryable; | ||
function fetch(endpoint) { | ||
function fetch(endpoint, options = {}) { | ||
return new Promise((resolve, reject) => { | ||
@@ -175,3 +175,3 @@ const parsedUrl = url_1.default.parse(endpoint); | ||
addErrorHandler(req, reject); | ||
addTimeout(req, reject); | ||
addTimeout(req, reject, options); | ||
}); | ||
@@ -194,4 +194,8 @@ } | ||
} | ||
function addTimeout(req, reject) { | ||
req.setTimeout(TIMEOUT_MS, () => { | ||
const minutesToMilliseconds = (minutes) => minutes * 60 * 1000; | ||
function addTimeout(req, reject, options) { | ||
const timeout = options.idleTimeout | ||
? minutesToMilliseconds(options.idleTimeout) | ||
: DEFAULT_TIMEOUT_MS; | ||
req.setTimeout(timeout, () => { | ||
const err = new NetworkError_1.NetworkError('Connection timed out'); | ||
@@ -198,0 +202,0 @@ err.code = NetworkError_1.NetworkErrorCode.TIMEOUT; |
@@ -15,6 +15,7 @@ /// <reference types="node" /> | ||
detectAppVersion?: boolean; | ||
idleTimeout?: number; | ||
requestOpts?: http.RequestOptions; | ||
logger?: Logger; | ||
} | ||
export declare function uploadOne({ apiKey, bundleUrl, bundle, sourceMap, appVersion, codeBundleId, overwrite, projectRoot, endpoint, detectAppVersion, requestOpts, logger, ...unknownArgs }: UploadSingleOpts): Promise<void>; | ||
export declare function uploadOne({ apiKey, bundleUrl, bundle, sourceMap, appVersion, codeBundleId, idleTimeout, overwrite, projectRoot, endpoint, detectAppVersion, requestOpts, logger, ...unknownArgs }: UploadSingleOpts): Promise<void>; | ||
interface UploadMultipleOpts { | ||
@@ -30,6 +31,7 @@ apiKey: string; | ||
detectAppVersion?: boolean; | ||
idleTimeout?: number; | ||
requestOpts?: http.RequestOptions; | ||
logger?: Logger; | ||
} | ||
export declare function uploadMultiple({ apiKey, baseUrl, directory, appVersion, codeBundleId, overwrite, detectAppVersion, projectRoot, endpoint, requestOpts, logger, ...unknownArgs }: UploadMultipleOpts): Promise<void>; | ||
export declare function uploadMultiple({ apiKey, baseUrl, directory, appVersion, codeBundleId, idleTimeout, overwrite, detectAppVersion, projectRoot, endpoint, requestOpts, logger, ...unknownArgs }: UploadMultipleOpts): Promise<void>; | ||
export {}; |
@@ -49,3 +49,3 @@ "use strict"; | ||
function uploadOne(_a) { | ||
var { apiKey, bundleUrl, bundle, sourceMap, appVersion, codeBundleId, overwrite = false, projectRoot = process.cwd(), endpoint = EndpointUrl_1.DEFAULT_UPLOAD_ORIGIN, detectAppVersion = false, requestOpts = {}, logger = Logger_1.noopLogger } = _a, unknownArgs = __rest(_a, ["apiKey", "bundleUrl", "bundle", "sourceMap", "appVersion", "codeBundleId", "overwrite", "projectRoot", "endpoint", "detectAppVersion", "requestOpts", "logger"]); | ||
var { apiKey, bundleUrl, bundle, sourceMap, appVersion, codeBundleId, idleTimeout, overwrite = false, projectRoot = process.cwd(), endpoint = EndpointUrl_1.DEFAULT_UPLOAD_ORIGIN, detectAppVersion = false, requestOpts = {}, logger = Logger_1.noopLogger } = _a, unknownArgs = __rest(_a, ["apiKey", "bundleUrl", "bundle", "sourceMap", "appVersion", "codeBundleId", "idleTimeout", "overwrite", "projectRoot", "endpoint", "detectAppVersion", "requestOpts", "logger"]); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -104,3 +104,3 @@ validateOneOpts({ | ||
overwrite: overwrite | ||
}, requestOpts); | ||
}, requestOpts, { idleTimeout }); | ||
const uploadedFiles = (bundleContent && fullBundlePath) ? `${sourceMap} and ${bundle}` : sourceMap; | ||
@@ -129,3 +129,3 @@ logger.success(`Success, uploaded ${uploadedFiles} to ${url} in ${(new Date()).getTime() - start}ms`); | ||
function uploadMultiple(_a) { | ||
var { apiKey, baseUrl, directory, appVersion, codeBundleId, overwrite = false, detectAppVersion = false, projectRoot = process.cwd(), endpoint = EndpointUrl_1.DEFAULT_UPLOAD_ORIGIN, requestOpts = {}, logger = Logger_1.noopLogger } = _a, unknownArgs = __rest(_a, ["apiKey", "baseUrl", "directory", "appVersion", "codeBundleId", "overwrite", "detectAppVersion", "projectRoot", "endpoint", "requestOpts", "logger"]); | ||
var { apiKey, baseUrl, directory, appVersion, codeBundleId, idleTimeout, overwrite = false, detectAppVersion = false, projectRoot = process.cwd(), endpoint = EndpointUrl_1.DEFAULT_UPLOAD_ORIGIN, requestOpts = {}, logger = Logger_1.noopLogger } = _a, unknownArgs = __rest(_a, ["apiKey", "baseUrl", "directory", "appVersion", "codeBundleId", "idleTimeout", "overwrite", "detectAppVersion", "projectRoot", "endpoint", "requestOpts", "logger"]); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -205,3 +205,3 @@ validateMultipleOpts({ | ||
overwrite: overwrite | ||
}, requestOpts); | ||
}, requestOpts, { idleTimeout }); | ||
const uploadedFiles = (bundleContent && fullBundlePath) ? `${sourceMap} and ${bundlePath}` : sourceMap; | ||
@@ -208,0 +208,0 @@ logger.success(`Success, uploaded ${uploadedFiles} to ${url} in ${(new Date()).getTime() - start}ms`); |
@@ -16,4 +16,5 @@ /// <reference types="node" /> | ||
logger?: Logger; | ||
idleTimeout?: number; | ||
} | ||
export declare function uploadOne({ apiKey, bundle, sourceMap, appVersion, codeBundleId, overwrite, projectRoot, endpoint, detectAppVersion, requestOpts, logger, ...unknownArgs }: UploadSingleOpts): Promise<void>; | ||
export declare function uploadOne({ apiKey, bundle, sourceMap, appVersion, codeBundleId, idleTimeout, overwrite, projectRoot, endpoint, detectAppVersion, requestOpts, logger, ...unknownArgs }: UploadSingleOpts): Promise<void>; | ||
interface UploadMultipleOpts { | ||
@@ -30,4 +31,5 @@ apiKey: string; | ||
logger?: Logger; | ||
idleTimeout?: number; | ||
} | ||
export declare function uploadMultiple({ apiKey, directory, appVersion, codeBundleId, overwrite, projectRoot, endpoint, detectAppVersion, requestOpts, logger, ...unknownArgs }: UploadMultipleOpts): Promise<void>; | ||
export declare function uploadMultiple({ apiKey, directory, appVersion, codeBundleId, idleTimeout, overwrite, projectRoot, endpoint, detectAppVersion, requestOpts, logger, ...unknownArgs }: UploadMultipleOpts): Promise<void>; | ||
export {}; |
@@ -49,3 +49,3 @@ "use strict"; | ||
function uploadOne(_a) { | ||
var { apiKey, bundle, sourceMap, appVersion, codeBundleId, overwrite = false, projectRoot = process.cwd(), endpoint = EndpointUrl_1.DEFAULT_UPLOAD_ORIGIN, detectAppVersion = false, requestOpts = {}, logger = Logger_1.noopLogger } = _a, unknownArgs = __rest(_a, ["apiKey", "bundle", "sourceMap", "appVersion", "codeBundleId", "overwrite", "projectRoot", "endpoint", "detectAppVersion", "requestOpts", "logger"]); | ||
var { apiKey, bundle, sourceMap, appVersion, codeBundleId, idleTimeout, overwrite = false, projectRoot = process.cwd(), endpoint = EndpointUrl_1.DEFAULT_UPLOAD_ORIGIN, detectAppVersion = false, requestOpts = {}, logger = Logger_1.noopLogger } = _a, unknownArgs = __rest(_a, ["apiKey", "bundle", "sourceMap", "appVersion", "codeBundleId", "idleTimeout", "overwrite", "projectRoot", "endpoint", "detectAppVersion", "requestOpts", "logger"]); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -99,3 +99,3 @@ validateOneOpts({ | ||
overwrite: overwrite | ||
}, requestOpts); | ||
}, requestOpts, { idleTimeout }); | ||
logger.success(`Success, uploaded ${sourceMap} and ${bundle} to ${url} in ${(new Date()).getTime() - start}ms`); | ||
@@ -123,3 +123,3 @@ } | ||
function uploadMultiple(_a) { | ||
var { apiKey, directory, appVersion, codeBundleId, overwrite = false, projectRoot = process.cwd(), endpoint = EndpointUrl_1.DEFAULT_UPLOAD_ORIGIN, detectAppVersion = false, requestOpts = {}, logger = Logger_1.noopLogger } = _a, unknownArgs = __rest(_a, ["apiKey", "directory", "appVersion", "codeBundleId", "overwrite", "projectRoot", "endpoint", "detectAppVersion", "requestOpts", "logger"]); | ||
var { apiKey, directory, appVersion, codeBundleId, idleTimeout, overwrite = false, projectRoot = process.cwd(), endpoint = EndpointUrl_1.DEFAULT_UPLOAD_ORIGIN, detectAppVersion = false, requestOpts = {}, logger = Logger_1.noopLogger } = _a, unknownArgs = __rest(_a, ["apiKey", "directory", "appVersion", "codeBundleId", "idleTimeout", "overwrite", "projectRoot", "endpoint", "detectAppVersion", "requestOpts", "logger"]); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -198,3 +198,3 @@ validateMultipleOpts({ | ||
overwrite: overwrite | ||
}, requestOpts); | ||
}, requestOpts, { idleTimeout }); | ||
const uploadedFiles = (bundleContent && fullBundlePath) ? `${sourceMap} and ${bundlePath}` : sourceMap; | ||
@@ -201,0 +201,0 @@ logger.success(`Success, uploaded ${uploadedFiles} to ${url} in ${(new Date()).getTime() - start}ms`); |
@@ -17,2 +17,3 @@ /// <reference types="node" /> | ||
logger?: Logger; | ||
idleTimeout?: number; | ||
} | ||
@@ -23,3 +24,3 @@ interface UploadSingleOpts extends CommonUploadOpts { | ||
} | ||
export declare function uploadOne({ apiKey, sourceMap, bundle, platform, dev, appVersion, codeBundleId, appVersionCode, appBundleVersion, overwrite, projectRoot, endpoint, requestOpts, logger, ...unknownArgs }: UploadSingleOpts): Promise<void>; | ||
export declare function uploadOne({ apiKey, sourceMap, bundle, platform, dev, appVersion, codeBundleId, appVersionCode, appBundleVersion, idleTimeout, overwrite, projectRoot, endpoint, requestOpts, logger, ...unknownArgs }: UploadSingleOpts): Promise<void>; | ||
interface FetchUploadOpts extends CommonUploadOpts { | ||
@@ -29,3 +30,3 @@ bundlerUrl?: string; | ||
} | ||
export declare function fetchAndUploadOne({ apiKey, platform, dev, appVersion, codeBundleId, appVersionCode, appBundleVersion, overwrite, projectRoot, endpoint, requestOpts, bundlerUrl, bundlerEntryPoint, logger, ...unknownArgs }: FetchUploadOpts): Promise<void>; | ||
export declare function fetchAndUploadOne({ apiKey, platform, dev, appVersion, codeBundleId, appVersionCode, appBundleVersion, idleTimeout, overwrite, projectRoot, endpoint, requestOpts, bundlerUrl, bundlerEntryPoint, logger, ...unknownArgs }: FetchUploadOpts): Promise<void>; | ||
export {}; |
@@ -68,3 +68,3 @@ "use strict"; | ||
function uploadOne(_a) { | ||
var { apiKey, sourceMap, bundle, platform, dev = false, appVersion, codeBundleId, appVersionCode, appBundleVersion, overwrite = true, projectRoot = process.cwd(), endpoint = EndpointUrl_1.DEFAULT_UPLOAD_ORIGIN, requestOpts = {}, logger = Logger_1.noopLogger } = _a, unknownArgs = __rest(_a, ["apiKey", "sourceMap", "bundle", "platform", "dev", "appVersion", "codeBundleId", "appVersionCode", "appBundleVersion", "overwrite", "projectRoot", "endpoint", "requestOpts", "logger"]); | ||
var { apiKey, sourceMap, bundle, platform, dev = false, appVersion, codeBundleId, appVersionCode, appBundleVersion, idleTimeout, overwrite = true, projectRoot = process.cwd(), endpoint = EndpointUrl_1.DEFAULT_UPLOAD_ORIGIN, requestOpts = {}, logger = Logger_1.noopLogger } = _a, unknownArgs = __rest(_a, ["apiKey", "sourceMap", "bundle", "platform", "dev", "appVersion", "codeBundleId", "appVersionCode", "appBundleVersion", "idleTimeout", "overwrite", "projectRoot", "endpoint", "requestOpts", "logger"]); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -105,3 +105,3 @@ validateOneOpts({ | ||
yield Request_1.default(url, Object.assign(Object.assign({ type: 1 /* ReactNative */, apiKey, sourceMap: new File_1.default(fullSourceMapPath, JSON.stringify(transformedSourceMap)), bundle: new File_1.default(fullBundlePath, bundleContent), platform, | ||
dev }, marshalledVersions), { overwrite }), requestOpts); | ||
dev }, marshalledVersions), { overwrite }), requestOpts, { idleTimeout }); | ||
logger.success(`Success, uploaded ${sourceMap} and ${bundle} to ${url} in ${(new Date()).getTime() - start}ms`); | ||
@@ -129,3 +129,3 @@ } | ||
function fetchAndUploadOne(_a) { | ||
var { apiKey, platform, dev = false, appVersion, codeBundleId, appVersionCode, appBundleVersion, overwrite = true, projectRoot = process.cwd(), endpoint = EndpointUrl_1.DEFAULT_UPLOAD_ORIGIN, requestOpts = {}, bundlerUrl = 'http://localhost:8081', bundlerEntryPoint = 'index.js', logger = Logger_1.noopLogger } = _a, unknownArgs = __rest(_a, ["apiKey", "platform", "dev", "appVersion", "codeBundleId", "appVersionCode", "appBundleVersion", "overwrite", "projectRoot", "endpoint", "requestOpts", "bundlerUrl", "bundlerEntryPoint", "logger"]); | ||
var { apiKey, platform, dev = false, appVersion, codeBundleId, appVersionCode, appBundleVersion, idleTimeout, overwrite = true, projectRoot = process.cwd(), endpoint = EndpointUrl_1.DEFAULT_UPLOAD_ORIGIN, requestOpts = {}, bundlerUrl = 'http://localhost:8081', bundlerEntryPoint = 'index.js', logger = Logger_1.noopLogger } = _a, unknownArgs = __rest(_a, ["apiKey", "platform", "dev", "appVersion", "codeBundleId", "appVersionCode", "appBundleVersion", "idleTimeout", "overwrite", "projectRoot", "endpoint", "requestOpts", "bundlerUrl", "bundlerEntryPoint", "logger"]); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -165,3 +165,3 @@ validateFetchOpts({ | ||
logger.debug(`Fetching source map from ${sourceMapUrl}`); | ||
sourceMap = yield Request_1.fetch(sourceMapUrl); | ||
sourceMap = yield Request_1.fetch(sourceMapUrl, { idleTimeout }); | ||
} | ||
@@ -174,3 +174,3 @@ catch (e) { | ||
logger.debug(`Fetching bundle from ${bundleUrl}`); | ||
bundle = yield Request_1.fetch(bundleUrl); | ||
bundle = yield Request_1.fetch(bundleUrl, { idleTimeout }); | ||
} | ||
@@ -189,3 +189,3 @@ catch (e) { | ||
yield Request_1.default(url, Object.assign(Object.assign({ type: 1 /* ReactNative */, apiKey, sourceMap: new File_1.default(sourceMapUrl, JSON.stringify(transformedSourceMap)), bundle: new File_1.default(bundleUrl, bundle), platform, | ||
dev }, marshalledVersions), { overwrite }), requestOpts); | ||
dev }, marshalledVersions), { overwrite }), requestOpts, { idleTimeout }); | ||
logger.success(`Success, uploaded ${entryPoint}.js.map to ${url} in ${(new Date()).getTime() - start}ms`); | ||
@@ -192,0 +192,0 @@ } |
{ | ||
"name": "@bugsnag/source-maps", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "CLI and JS library for uploading source maps to Bugsnag", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
162660
2288
3