@babblevoice/babble-drachtio-callmanager 3.10.0 → 3.10.2

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.
Files changed (2) hide show
  1. package/lib/call.js +32 -8
  2. package/package.json +1 -1
package/lib/call.js CHANGED
@@ -1354,12 +1354,19 @@ class call {
1354
1354
  /* When we adopt-and-mix (enterprise queues and ring groups connect this
1355
1355
  way rather than via #answerparent) we are the parent leg. preconnect
1356
1356
  runs before the mix (projectrtp cannot play into a mixing channel),
1357
- then we mix, then postconnect. */
1357
+ then we mix, then postconnect. Only take the deferred (hook) path when a
1358
+ hook is actually registered - otherwise mix synchronously in this tick,
1359
+ exactly as before, so callers that assume the mix has been issued on
1360
+ return (recording, queue setup) don't race a microtask. */
1358
1361
  if( mix ) {
1359
- this.#notifyconnecthook( this, other, "preconnect" )
1360
- .then( () => this.mix( other ) )
1361
- .then( () => this.#notifyconnecthook( this, other, "postconnect" ) )
1362
- .catch( ( e ) => console.trace( e ) )
1362
+ if( this.callbacks && ( this.callbacks.preconnect || this.callbacks.postconnect ) ) {
1363
+ this.#notifyconnecthook( this, other, "preconnect" )
1364
+ .then( () => this.mix( other ) )
1365
+ .then( () => this.#notifyconnecthook( this, other, "postconnect" ) )
1366
+ .catch( ( e ) => console.trace( e ) )
1367
+ } else {
1368
+ this.mix( other )
1369
+ }
1363
1370
  }
1364
1371
  return this
1365
1372
  }
@@ -1534,8 +1541,13 @@ class call {
1534
1541
  /* preconnect: our parent leg's handler runs BEFORE the mix. projectrtp
1535
1542
  cannot play audio into a channel that is being mixed, so a prompt that
1536
1543
  must be heard on connect is played to each leg separately here (both
1537
- channels are open by this point), then we mix. */
1538
- await this.#notifyconnecthook( this.parent, this, "preconnect" )
1544
+ channels are open by this point), then we mix. Only yield when a hook is
1545
+ actually registered - a normal bridge must mix synchronously in this tick
1546
+ exactly as before, or recording/queue setup that assumes the mix has been
1547
+ issued can race. */
1548
+ if( this.parent.callbacks.preconnect ) {
1549
+ await this.#notifyconnecthook( this.parent, this, "preconnect" )
1550
+ }
1539
1551
 
1540
1552
  this.channels.audio.mix( this.parent.channels.audio )
1541
1553
 
@@ -1558,7 +1570,9 @@ class call {
1558
1570
  }
1559
1571
  }
1560
1572
 
1561
- await this.#notifyconnecthook( this.parent, this, "postconnect" )
1573
+ if( this.parent.callbacks.postconnect ) {
1574
+ await this.#notifyconnecthook( this.parent, this, "postconnect" )
1575
+ }
1562
1576
 
1563
1577
  return this
1564
1578
  }
@@ -4280,6 +4294,16 @@ class call {
4280
4294
  newcall._onring()
4281
4295
  } else if( 183 === res.status ) {
4282
4296
  earlypromise = newcall._onearly()
4297
+ /* Early media: the far end is progressing (e.g. a carrier sending
4298
+ 183 Session Progress that answers only after the ring timeout
4299
+ would fire). _onearly clears the ring timer (_timers.newuac);
4300
+ also clear the settle watchdog so it doesn't tear the call down
4301
+ with a REQUEST_TIMEOUT before the (late) answer arrives. The SIP
4302
+ transaction layer remains the backstop if it never answers. */
4303
+ if( settlewatchdog ) {
4304
+ clearTimeout( settlewatchdog )
4305
+ settlewatchdog = undefined
4306
+ }
4283
4307
  }
4284
4308
 
4285
4309
  if( newcall.canceled ) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babblevoice/babble-drachtio-callmanager",
3
- "version": "3.10.0",
3
+ "version": "3.10.2",
4
4
  "description": "Call processing to create a PBX",
5
5
  "main": "index.js",
6
6
  "scripts": {