masterrecord 1.5.14 → 1.5.15
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/CHANGES.md +8 -0
- package/context.js +7 -0
- package/package.json +1 -1
package/CHANGES.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# MasterRecord Changelog
|
|
2
2
|
|
|
3
|
+
## v1.5.15 — close() releases the change tracker (EF Dispose parity for request-scoped contexts)
|
|
4
|
+
|
|
5
|
+
EF Core's bounded-memory model is a short-lived, request-scoped `DbContext` that is **disposed** per unit of work — disposal releases the whole `ChangeTracker`. masterrecord's `close()` did everything *except* that: it dropped the live-context registration and the connection-pool ref, but left the tracked-entity map and dirty index populated, so a scoped context only freed its entities when the context object itself was GC'd.
|
|
6
|
+
|
|
7
|
+
`close()` now calls `__clearTracked()` first — detaching every tracked entity and clearing the dirty index — so a request-scoped context frees all its entities immediately on close. This makes request-scoped contexts the clean, EF-faithful bounded-memory answer: `new AppContext()` per request → work → `await ctx.close()`.
|
|
8
|
+
|
|
9
|
+
No new API; behavior only. Full suite green (0 fail, 309 pass, 20 gated skipped); 0 lint errors.
|
|
10
|
+
|
|
3
11
|
## v1.5.14 — context-level query tracking behavior (EF's QueryTrackingBehavior) + asTracking()
|
|
4
12
|
|
|
5
13
|
The remaining memory issue: on a long-lived/singleton context, tracked entities are held with **strong references** for the life of the context, so read-only queries that track their results grow the tracked set without bound. `asNoTracking()` (1.5.13) bounds it only per call site.
|
package/context.js
CHANGED
|
@@ -2631,6 +2631,13 @@ class context {
|
|
|
2631
2631
|
* db.close(); // Close connections
|
|
2632
2632
|
*/
|
|
2633
2633
|
async close() {
|
|
2634
|
+
// Release the change tracker (EF's Dispose clears the ChangeTracker):
|
|
2635
|
+
// detach every tracked entity and drop the dirty index so a request-
|
|
2636
|
+
// scoped context frees all its entities immediately on close, instead of
|
|
2637
|
+
// only when the context object itself is garbage-collected. This is what
|
|
2638
|
+
// makes scoped contexts the bounded-memory answer.
|
|
2639
|
+
this.__clearTracked();
|
|
2640
|
+
|
|
2634
2641
|
// Deregister from the live-context registry so it stops appearing in
|
|
2635
2642
|
// cross-context checks and doesn't linger until GC.
|
|
2636
2643
|
//
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "masterrecord",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.15",
|
|
4
4
|
"description": "An Object-relational mapping for the Master framework. Master Record connects classes to relational database tables to establish a database with almost zero-configuration ",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./MasterRecord.js",
|