repro-nest 0.0.201 → 0.0.203

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.
package/dist/index.js CHANGED
@@ -1289,6 +1289,27 @@ function reproMiddleware(cfg) {
1289
1289
  depth: evt.depth,
1290
1290
  library: inferLibraryNameFromFile(evt.file),
1291
1291
  };
1292
+ if (evt.type === 'exit') {
1293
+ // If the function returned a Mongoose Query, update the exit value when the query settles.
1294
+ const rv = ev.returnValue;
1295
+ const setReturnValue = (val) => {
1296
+ try {
1297
+ evt.returnValue = sanitizeTraceValue(val);
1298
+ }
1299
+ catch { }
1300
+ };
1301
+ const qp = rv && rv.__repro_result_promise;
1302
+ const hasResult = rv && Object.prototype.hasOwnProperty.call(rv, '__repro_result');
1303
+ if (hasResult) {
1304
+ setReturnValue(rv.__repro_result);
1305
+ }
1306
+ else if (qp && typeof qp.then === 'function') {
1307
+ try {
1308
+ qp.then((val) => setReturnValue(val), () => { });
1309
+ }
1310
+ catch { }
1311
+ }
1312
+ }
1292
1313
  const spanKey = normalizeSpanId(evt.spanId);
1293
1314
  if (evt.type === 'enter') {
1294
1315
  lastEventAt = Date.now();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repro-nest",
3
- "version": "0.0.201",
3
+ "version": "0.0.203",
4
4
  "description": "Repro Nest SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -1499,6 +1499,26 @@ export function reproMiddleware(cfg: ReproMiddlewareConfig) {
1499
1499
  library: inferLibraryNameFromFile(evt.file),
1500
1500
  };
1501
1501
 
1502
+ if (evt.type === 'exit') {
1503
+ // If the function returned a Mongoose Query, update the exit value when the query settles.
1504
+ const rv: any = ev.returnValue;
1505
+ const setReturnValue = (val: any) => {
1506
+ try { evt.returnValue = sanitizeTraceValue(val); } catch {}
1507
+ };
1508
+ const qp = rv && rv.__repro_result_promise;
1509
+ const hasResult = rv && Object.prototype.hasOwnProperty.call(rv, '__repro_result');
1510
+ if (hasResult) {
1511
+ setReturnValue(rv.__repro_result);
1512
+ } else if (qp && typeof qp.then === 'function') {
1513
+ try {
1514
+ qp.then(
1515
+ (val: any) => setReturnValue(val),
1516
+ () => {}
1517
+ );
1518
+ } catch {}
1519
+ }
1520
+ }
1521
+
1502
1522
  const spanKey = normalizeSpanId(evt.spanId);
1503
1523
  if (evt.type === 'enter') {
1504
1524
  lastEventAt = Date.now();
package/tracer/runtime.js CHANGED
@@ -645,11 +645,6 @@ if (!global.__repro_call) {
645
645
  }
646
646
  } catch {}
647
647
 
648
- if (isQuery) {
649
- runExit(exitDetailBase);
650
- return out;
651
- }
652
-
653
648
  let settled = false;
654
649
  const finalize = (value, threw, error) => {
655
650
  if (settled) return value;