Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CN - Minor decision tree logging fixes #3744

Merged
merged 2 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions creator-node/src/fileManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ async function saveFileForMultihashToFS(
gatewayUrlsMapped,
expectedStoragePath,
parsedStoragePath
}
},
log: true
})

// Create dir at expected storage path in which to store retrieved data
Expand Down Expand Up @@ -213,8 +214,7 @@ async function saveFileForMultihashToFS(
if (await fs.pathExists(expectedStoragePath)) {
decisionTree.recordStage({
name: 'Success - File already stored on disk',
data: { expectedStoragePath },
log: true
data: { expectedStoragePath }
})

return
Expand Down Expand Up @@ -260,8 +260,7 @@ async function saveFileForMultihashToFS(
} catch (e) {
decisionTree.recordStage({
name: 'Error - Could not retrieve file from gateway',
data: { url, errorMsg: e.message },
log: true
data: { url, errorMsg: e.message }
})
continue
}
Expand All @@ -283,15 +282,13 @@ async function saveFileForMultihashToFS(

decisionTree.recordStage({
name: 'Wrote file to file system after fetching from gateway',
data: { expectedStoragePath },
log: true
data: { expectedStoragePath }
})
} catch (e) {
const errorMsg = `Failed to retrieve file for multihash ${multihash} from other creator node gateways`
decisionTree.recordStage({
name: errorMsg,
data: { errorMsg: e.message },
log: true
data: { errorMsg: e.message }
})
}
}
Expand Down Expand Up @@ -393,14 +390,15 @@ async function saveFileForMultihashToFS(
} catch (e) {
decisionTree.recordStage({
name: `Uncaught Error`,
data: { errorMsg: e.message },
log: true
data: { errorMsg: e.message }
})

return e
} finally {
decisionTree.printTree()
}

// Else return nothing
// If no error, return nothing
}

/**
Expand Down
2 changes: 1 addition & 1 deletion creator-node/src/services/sync/primarySyncFromSecondary.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = async function primarySyncFromSecondary({

// Error if this node is not primary for user
if (userReplicaSet[0] !== selfEndpoint) {
decisionTree.recordState({
decisionTree.recordStage({
name: 'Error - Node is not primary for user',
data: { userReplicaSet }
})
Expand Down
2 changes: 1 addition & 1 deletion creator-node/src/utils/decisionTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = class DecisionTree {
data,
timestamp,
duration,
fullDuration: previousStage.duration + duration
fullDuration: previousStage.fullDuration + duration
}
} else {
stage = {
Expand Down