taist 0.1.12 → 0.1.14

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.
@@ -21,6 +21,10 @@ export class TraceReporter extends EventEmitter {
21
21
  this.flushInterval = options.flushInterval || 1000;
22
22
  this.maxRetries = options.maxRetries || 3;
23
23
  this.retryDelay = options.retryDelay || 100;
24
+ // Immediate flush mode - sends each trace immediately instead of buffering
25
+ // This is the default to prevent trace loss on process exit
26
+ // Set TAIST_BUFFER_TRACES=true to enable batching for high-throughput scenarios
27
+ this.flushImmediate = options.flushImmediate ?? (process.env.TAIST_BUFFER_TRACES !== 'true');
24
28
 
25
29
  this.buffer = [];
26
30
  this.socket = null;
@@ -32,7 +36,7 @@ export class TraceReporter extends EventEmitter {
32
36
  this.closed = false;
33
37
  this.shuttingDown = false; // Prevents race between shutdown signal and SIGTERM
34
38
 
35
- logger.debug("[reporter] Created with socketPath:", this.socketPath);
39
+ logger.debug("[reporter] Created with socketPath:", this.socketPath, "flushImmediate:", this.flushImmediate);
36
40
 
37
41
  // Auto-setup if socket path is available
38
42
  if (this.socketPath) {
@@ -254,8 +258,11 @@ export class TraceReporter extends EventEmitter {
254
258
  });
255
259
  }
256
260
 
257
- // Auto-flush when batch size reached
258
- if (this.buffer.length >= this.batchSize) {
261
+ // Flush immediately if configured (for spawned processes with unpredictable exit)
262
+ // Otherwise auto-flush when batch size reached
263
+ if (this.flushImmediate) {
264
+ this.flush().catch(() => {});
265
+ } else if (this.buffer.length >= this.batchSize) {
259
266
  this.flush().catch(() => {});
260
267
  }
261
268
  }
package/lib/transform.js CHANGED
@@ -145,13 +145,16 @@ export function transformSource(source, moduleNameOrOptions, tracerImportPath) {
145
145
  import { getGlobalReporter as __taist_getReporter } from "${reporterPath}";
146
146
  import { getContext as __taist_getContext, runWithContext as __taist_runWithContext, generateId as __taist_generateId } from "${traceContextPath}";
147
147
  const __taist_reporter = __taist_getReporter();
148
+ const __taist_debug = process.env.TAIST_DEBUG === 'true';
148
149
  // Eagerly connect to collector if socket path is set (build-time instrumentation)
149
150
  if (process.env.TAIST_COLLECTOR_SOCKET && !__taist_reporter.isConnected()) {
150
151
  __taist_reporter.connectEager();
151
152
  }
152
153
  const __taist_wrap = (fn, name) => {
153
154
  if (typeof fn !== 'function') return fn;
155
+ if (__taist_debug) console.log('[taist] wrapping:', name);
154
156
  const wrapped = function(...args) {
157
+ if (__taist_debug) console.log('[taist] CALLED:', name);
155
158
  const parentCtx = __taist_getContext();
156
159
  const id = __taist_generateId();
157
160
  const depth = parentCtx.depth;
@@ -218,10 +221,12 @@ const __taist_instrumentClass = (cls, name) => {
218
221
  };
219
222
  const __taist_instrumentObject = (obj, name, visited = new WeakSet()) => {
220
223
  if (!obj || typeof obj !== 'object' || visited.has(obj)) return obj;
224
+ if (__taist_debug) console.log('[taist] instrumentObject:', name, Object.keys(obj));
221
225
  visited.add(obj);
222
226
  for (const key of Object.keys(obj)) {
223
227
  const value = obj[key];
224
228
  if (typeof value === 'function') {
229
+ if (__taist_debug) console.log('[taist] found method:', name + '.' + key);
225
230
  obj[key] = __taist_wrap(value, name + '.' + key);
226
231
  } else if (value && typeof value === 'object' && !Array.isArray(value)) {
227
232
  __taist_instrumentObject(value, name + '.' + key, visited);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taist",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "Token-Optimized Testing Framework for AI-Assisted Development",
5
5
  "main": "index.js",
6
6
  "type": "module",