@openwop/openwop-conformance 2.45.23 → 2.45.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -137,7 +137,18 @@ export async function startEffectReceiver(opts: EffectReceiverOptions = {}): Pro
137
137
  const pinned = Number(process.env['OPENWOP_WEBHOOK_RECEIVER_PORT'] ?? '');
138
138
  const bindPort = Number.isInteger(pinned) && pinned > 0 && pinned < 65536 ? pinned : 0;
139
139
  const binding = receiverBinding();
140
- await new Promise<void>((resolve) => server.listen(bindPort, binding.bind, () => resolve()));
140
+ // A pinned port already held (another process, or another listener in this
141
+ // one) emits `error`, not the listen callback. Without this handler the promise
142
+ // never settled and a duplicate-delivery leg hung to its 180 s timeout instead
143
+ // of failing with the cause (MyndHyve's 2.45.18 cut, port 8787; scoped-receiver
144
+ // has had the same handler since 2.39.3).
145
+ await new Promise<void>((resolve, reject) => {
146
+ const onError = (err: Error): void => {
147
+ reject(new Error(`effect receiver could not bind ${binding.bind}:${bindPort} — ${err.message}. A pinned OPENWOP_WEBHOOK_RECEIVER_PORT must be free for this process (another process holds it?)`));
148
+ };
149
+ server.once('error', onError);
150
+ server.listen(bindPort, binding.bind, () => { server.off('error', onError); resolve(); });
151
+ });
141
152
  const addr = server.address();
142
153
  const port = typeof addr === 'object' && addr ? addr.port : 0;
143
154
  const localUrl = `http://${binding.advertise}:${port}${path}`;