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