@tmlmobilidade/controllers 20260201.1250.27 → 20260203.1103.48

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.
@@ -113,7 +113,7 @@ export class RidesSharedController {
113
113
  //
114
114
  // Start a watch service for the database
115
115
  // and send updates to the client as they occur.
116
- ridesCollection
116
+ const changeStream = ridesCollection
117
117
  .watch([], { fullDocument: 'updateLookup' })
118
118
  .on('change', (databaseOperation) => {
119
119
  if (typeof databaseOperation['fullDocument'] === 'undefined') {
@@ -126,8 +126,15 @@ export class RidesSharedController {
126
126
  error: null,
127
127
  statusCode: HttpStatus.OK,
128
128
  };
129
- socket.send(JSON.stringify(message));
129
+ if (socket.readyState === socket.OPEN && socket.bufferedAmount < 1_000_000) {
130
+ socket.send(JSON.stringify(message));
131
+ }
130
132
  });
133
+ const cleanup = async () => {
134
+ await changeStream.close();
135
+ };
136
+ socket.on('close', cleanup);
137
+ socket.on('error', cleanup);
131
138
  //
132
139
  });
133
140
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/controllers",
3
- "version": "20260201.1250.27",
3
+ "version": "20260203.1103.48",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"