Skip to content

Commit

Permalink
fix: safeguard api calls (#1103)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhousley authored Jul 8, 2024
1 parent 83d7d1e commit 3d815a3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/loaders/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export function setTopLevelCallers () {
function caller (fnName, ...args) {
let returnVals = []
Object.values(nr.initializedAgents).forEach(val => {
if (val.exposed && val.api[fnName]) {
if (!val || !val.api) {
warn(`Call to api '${fnName}' made before agent fully initialized.`)
} else if (val.exposed && val.api[fnName]) {
returnVals.push(val.api[fnName](...args))
}
})
Expand Down

0 comments on commit 3d815a3

Please sign in to comment.