flexbiz-server 12.3.63 → 12.3.64

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "flexbiz-server",
3
3
  "main": "./server/app.js",
4
4
  "description": "Flexible Server",
5
- "version": "12.3.63",
5
+ "version": "12.3.64",
6
6
  "author": {
7
7
  "name": "Van Truong Pham",
8
8
  "email": "invncur@gmail.com"
@@ -118,6 +118,9 @@ exports.handlerWithSession = async function (handler, ctrl, req, callback, ...ex
118
118
  // --- THÀNH CÔNG ---
119
119
  await session.endSession().catch(() => {});
120
120
 
121
+ //xoá session khởi store cho an toán
122
+ (exports.getCurrentStore()||{}).session = null;
123
+
121
124
  // Chạy onAfterCommit SAU KHI session đã đóng
122
125
  if (afterCommitCallbacks.length > 0) {
123
126
  console.log(`🔥 [onAfterCommit] running storeId=${storeId_for_log}, count=${afterCommitCallbacks.length}`);
@@ -125,6 +128,7 @@ exports.handlerWithSession = async function (handler, ctrl, req, callback, ...ex
125
128
  try { await cb(); } catch (err) { console.error("❌ [onAfterCommit error]", err); }
126
129
  }
127
130
  }
131
+
128
132
 
129
133
  callback(null, result); // Gọi callback thành công cuối cùng
130
134
  return; // Thoát khỏi hàm, vì đã thành công
@@ -133,6 +137,9 @@ exports.handlerWithSession = async function (handler, ctrl, req, callback, ...ex
133
137
  // --- THẤT BẠI (TRONG PROMISE) ---
134
138
  await session.endSession().catch(() => {}); // Luôn đóng session khi lỗi
135
139
 
140
+ //xoá session khởi store cho an toán
141
+ (exports.getCurrentStore()||{}).session = null;
142
+
136
143
  attempt++;
137
144
  const isTransient =
138
145
  err?.errorLabels?.includes("TransientTransactionError") ||
@@ -167,10 +174,10 @@ exports.handlerWithSession = async function (handler, ctrl, req, callback, ...ex
167
174
  */
168
175
  exports.onAfterCommit = function (cb) {
169
176
  const store = storage.getStore();
170
- if (store && store.session) {
177
+ if (store && store.session && exports.isSessionActive(store.session)) {
171
178
  store.session.afterCommit = store.session.afterCommit || [];
172
179
  store.session.afterCommit.push(cb);
173
- console.log(`🔥 [onAfterCommit] added event.. storeId=${store.storeId}, count=${store.session.afterCommit.length}`);
180
+ console.log(`[onAfterCommit] added event.. storeId=${store.storeId}, count=${store.session.afterCommit.length}, ctrl=${store.session.ctrl_name}`);
174
181
  } else {
175
182
  // Không có session → chạy ngay
176
183
  //console.log("[onAfterCommit] no session, running immediately");