anear-js-api 1.1.4 → 1.1.5

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.
@@ -763,7 +763,7 @@ const ActiveEventStatesConfig = {
763
763
  src: 'detachChannels',
764
764
  input: ({ context, event }) => ({ context, event }),
765
765
  onDone: {
766
- target: '#activeEvent.doneExit'
766
+ target: '#activeEvent.doneExit.notifyingExit'
767
767
  }
768
768
  }
769
769
  }
@@ -835,7 +835,7 @@ const ActiveEventStatesConfig = {
835
835
  src: 'detachChannels',
836
836
  input: ({ context, event }) => ({ context, event }),
837
837
  onDone: {
838
- target: '#activeEvent.doneExit'
838
+ target: '#activeEvent.doneExit.notifyingExit'
839
839
  },
840
840
  onError: {
841
841
  target: '#activeEvent.failure'
@@ -902,7 +902,7 @@ const ActiveEventStatesConfig = {
902
902
  src: 'detachChannels',
903
903
  input: ({ context, event }) => ({ context, event }),
904
904
  onDone: {
905
- target: '#activeEvent.doneExit'
905
+ target: '#activeEvent.doneExit.notifyingExit'
906
906
  },
907
907
  onError: {
908
908
  target: '#activeEvent.failure'
@@ -961,7 +961,7 @@ const ActiveEventStatesConfig = {
961
961
  src: 'detachChannels',
962
962
  input: ({ context, event }) => ({ context, event }),
963
963
  onDone: {
964
- target: '#activeEvent.doneExit'
964
+ target: '#activeEvent.doneExit.notifyingExit'
965
965
  },
966
966
  onError: {
967
967
  target: '#activeEvent.failure'
@@ -986,9 +986,29 @@ const ActiveEventStatesConfig = {
986
986
  }
987
987
  },
988
988
  doneExit: {
989
+ // Final cleanup for *all* termination paths.
990
+ //
991
+ // Some shutdown paths already detach channels explicitly (close/cancel/suspend),
992
+ // but other paths (notably failure → doneExit) previously skipped detach entirely.
993
+ // Leaving event-scoped channels attached causes Ably to attempt recovery/reattach
994
+ // on every reconnect, creating noise and unnecessary resource usage.
989
995
  id: 'doneExit',
990
- entry: 'notifyCoreServiceMachineExit',
991
- type: 'final'
996
+ initial: 'detaching',
997
+ states: {
998
+ detaching: {
999
+ invoke: {
1000
+ src: 'detachChannels',
1001
+ input: ({ context, event }) => ({ context, event }),
1002
+ onDone: 'notifyingExit',
1003
+ // If detach fails, still notify ACSM so it can clean up this AEM.
1004
+ onError: 'notifyingExit'
1005
+ }
1006
+ },
1007
+ notifyingExit: {
1008
+ entry: 'notifyCoreServiceMachineExit',
1009
+ type: 'final'
1010
+ }
1011
+ }
992
1012
  },
993
1013
  failure: {
994
1014
  id: 'failure',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anear-js-api",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Javascript Developer API for Anear Apps",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {