Skip to content

Commit

Permalink
fix: refactor to use current (3.x) async package (#1018)
Browse files Browse the repository at this point in the history
  • Loading branch information
waltjones committed Apr 12, 2022
1 parent 31082d7 commit b645d0a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 53 deletions.
48 changes: 10 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -11,7 +11,7 @@
"browser": "dist/rollbar.umd.min.js",
"types": "./index.d.ts",
"dependencies": {
"async": "~1.2.1",
"async": "~3.2.3",
"console-polyfill": "0.3.0",
"error-stack-parser": "^2.0.4",
"json-stringify-safe": "~5.0.0",
Expand Down
26 changes: 12 additions & 14 deletions src/server/parser.js
Expand Up @@ -181,7 +181,7 @@ function shouldReadFrameFile(frameFilename, callback) {
isCached = !!cache.get(frameFilename);
isPending = !!pendingReads[frameFilename];

callback(isValidFilename && !isCached && !isPending);
callback(null, isValidFilename && !isCached && !isPending);
}


Expand All @@ -201,19 +201,13 @@ function readFileLines(filename, callback) {
}
}


/* Older versions of node do not have fs.exists so we implement our own */
function checkFileExists(filename, callback) {
if (stackTrace.sourceContent(filename)) {
return callback(true);
}
if (fs.exists !== undefined) {
fs.exists(filename, callback);
} else {
fs.stat(filename, function (err) {
callback(!err);
});
return callback(null, true);
}
fs.stat(filename, function (err) {
callback(null, !err);
});
}


Expand All @@ -226,7 +220,9 @@ function gatherContexts(frames, callback) {
}
});

async.filter(frameFilenames, shouldReadFrameFile, function (results) {
async.filter(frameFilenames, shouldReadFrameFile, function (err, results) {
if (err) return callback(err);

var tempFileCache;

tempFileCache = {};
Expand Down Expand Up @@ -270,7 +266,8 @@ function gatherContexts(frames, callback) {
callback(null);
}

async.filter(results, checkFileExists, function (filenames) {
async.filter(results, checkFileExists, function (err, filenames) {
if (err) return callback(err);
async.each(filenames, gatherFileData, function (err) {
if (err) {
return callback(err);
Expand Down Expand Up @@ -367,7 +364,8 @@ exports.parseStack = function (stack, options, item, callback) {
return callback(err);
}
frames.reverse();
async.filter(frames, function (frame, callback) { callback(!!frame); }, function (results) {
async.filter(frames, function (frame, callback) { callback(null, !!frame); }, function (err, results) {
if (err) return callback(err);
gatherContexts(results, callback);
});
});
Expand Down

0 comments on commit b645d0a

Please sign in to comment.