Skip to content

Commit b645d0a

Browse files
authored
fix: refactor to use current (3.x) async package (#1018)
1 parent 31082d7 commit b645d0a

File tree

3 files changed

+23
-53
lines changed

3 files changed

+23
-53
lines changed

package-lock.json

+10-38
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"browser": "dist/rollbar.umd.min.js",
1212
"types": "./index.d.ts",
1313
"dependencies": {
14-
"async": "~1.2.1",
14+
"async": "~3.2.3",
1515
"console-polyfill": "0.3.0",
1616
"error-stack-parser": "^2.0.4",
1717
"json-stringify-safe": "~5.0.0",

src/server/parser.js

+12-14
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ function shouldReadFrameFile(frameFilename, callback) {
181181
isCached = !!cache.get(frameFilename);
182182
isPending = !!pendingReads[frameFilename];
183183

184-
callback(isValidFilename && !isCached && !isPending);
184+
callback(null, isValidFilename && !isCached && !isPending);
185185
}
186186

187187

@@ -201,19 +201,13 @@ function readFileLines(filename, callback) {
201201
}
202202
}
203203

204-
205-
/* Older versions of node do not have fs.exists so we implement our own */
206204
function checkFileExists(filename, callback) {
207205
if (stackTrace.sourceContent(filename)) {
208-
return callback(true);
209-
}
210-
if (fs.exists !== undefined) {
211-
fs.exists(filename, callback);
212-
} else {
213-
fs.stat(filename, function (err) {
214-
callback(!err);
215-
});
206+
return callback(null, true);
216207
}
208+
fs.stat(filename, function (err) {
209+
callback(null, !err);
210+
});
217211
}
218212

219213

@@ -226,7 +220,9 @@ function gatherContexts(frames, callback) {
226220
}
227221
});
228222

229-
async.filter(frameFilenames, shouldReadFrameFile, function (results) {
223+
async.filter(frameFilenames, shouldReadFrameFile, function (err, results) {
224+
if (err) return callback(err);
225+
230226
var tempFileCache;
231227

232228
tempFileCache = {};
@@ -270,7 +266,8 @@ function gatherContexts(frames, callback) {
270266
callback(null);
271267
}
272268

273-
async.filter(results, checkFileExists, function (filenames) {
269+
async.filter(results, checkFileExists, function (err, filenames) {
270+
if (err) return callback(err);
274271
async.each(filenames, gatherFileData, function (err) {
275272
if (err) {
276273
return callback(err);
@@ -367,7 +364,8 @@ exports.parseStack = function (stack, options, item, callback) {
367364
return callback(err);
368365
}
369366
frames.reverse();
370-
async.filter(frames, function (frame, callback) { callback(!!frame); }, function (results) {
367+
async.filter(frames, function (frame, callback) { callback(null, !!frame); }, function (err, results) {
368+
if (err) return callback(err);
371369
gatherContexts(results, callback);
372370
});
373371
});

0 commit comments

Comments
 (0)