(promise, timeoutMs)
| 212 | } |
| 213 | |
| 214 | function _withTimeout(promise, timeoutMs) { |
| 215 | return Promise.race([ |
| 216 | promise, |
| 217 | new Promise(function (resolve) { |
| 218 | setTimeout(function () { resolve({ ok: false, error: 'autobuyer_timeout' }); }, timeoutMs); |
| 219 | }), |
| 220 | ]); |
| 221 | } |
| 222 | |
| 223 | // Single-flight queue: serialize the read → cap-check → placeOrder → write |
| 224 | // pipeline so two concurrent considerOrder() calls cannot both pass the cap |
no outgoing calls
no test coverage detected