Skip to content

Commit

Permalink
Merge pull request #14 from CGNonofr/always-call-callback
Browse files Browse the repository at this point in the history
Always call the callback
  • Loading branch information
itsfadnis authored Mar 16, 2020
2 parents 5d4e9f4 + 719c3b3 commit d4a0bc5
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,17 @@ module.exports = class DatadogTransport extends Transport {
const queryString = querystring.encode(query)
const api = querystring ? `${this.api}?${queryString}` : this.api

// Perform the writing to the remote service
await fetch(api, {
method: 'POST',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify(logs)
})
callback()
try {
// Perform the writing to the remote service
await fetch(api, {
method: 'POST',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify(logs)
})
} finally {
callback()
}
}
}

0 comments on commit d4a0bc5

Please sign in to comment.