| 895 | |
| 896 | let cbAlreadyCalled = false |
| 897 | function cb (err, value) { |
| 898 | if (cbAlreadyCalled) return |
| 899 | cbAlreadyCalled = true |
| 900 | handled++ |
| 901 | |
| 902 | // we can safely ignore error for trailer |
| 903 | // since it does affect the client |
| 904 | // we log in here only for debug usage |
| 905 | if (err) reply.log.debug(err) |
| 906 | else trailers[trailerName] = value |
| 907 | |
| 908 | // we push the check to the end of event |
| 909 | // loop, so the registration continue to |
| 910 | // process. |
| 911 | process.nextTick(send) |
| 912 | } |
| 913 | |
| 914 | const result = reply[kReplyTrailers][trailerName](reply, payload, cb) |
| 915 | if (typeof result === 'object' && typeof result.then === 'function') { |