metergraph 0.6.14 → 0.6.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.
@@ -21,6 +21,7 @@ export declare class Transport {
21
21
  private scheduled;
22
22
  private inFlight;
23
23
  private fatal;
24
+ private upload?;
24
25
  private dropped;
25
26
  private errors;
26
27
  private retryAt;
package/dist/transport.js CHANGED
@@ -28,6 +28,7 @@ class Transport {
28
28
  scheduled = false;
29
29
  inFlight = Promise.resolve();
30
30
  fatal = false;
31
+ upload;
31
32
  dropped = 0;
32
33
  errors = 0;
33
34
  retryAt = 0;
@@ -127,9 +128,18 @@ class Transport {
127
128
  await this.deliver(rows.slice(midpoint));
128
129
  return;
129
130
  }
131
+ if (this.fatal) {
132
+ this.dropped += rows.length;
133
+ return;
134
+ }
135
+ const controller = new AbortController();
136
+ this.upload = controller;
137
+ const timeout = setTimeout(() => controller.abort(), 30_000);
138
+ timeout.unref?.();
130
139
  try {
131
140
  const response = await fetch(`${this.baseUrl.replace(/\/$/, "")}/v1/ingest`, {
132
141
  method: "POST",
142
+ signal: controller.signal,
133
143
  headers: {
134
144
  Authorization: `Bearer ${token}`,
135
145
  "Content-Type": "application/json",
@@ -171,11 +181,20 @@ class Transport {
171
181
  this.markTransientFailure(rows.length);
172
182
  this.failureLog.report("transport_error", `ingest request to ${this.baseUrl} failed: ${error instanceof Error ? error.message : String(error)}`);
173
183
  }
184
+ finally {
185
+ clearTimeout(timeout);
186
+ if (this.upload === controller)
187
+ this.upload = undefined;
188
+ }
174
189
  }
175
190
  async shutdown() {
176
191
  if (this.timer)
177
192
  clearInterval(this.timer);
178
193
  await this.flush();
194
+ this.fatal = true;
195
+ this.dropped += this.queue.length;
196
+ this.queue.length = 0;
197
+ this.upload?.abort();
179
198
  }
180
199
  }
181
200
  exports.Transport = Transport;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.6.14";
1
+ export declare const SDK_VERSION = "0.6.15";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.6.14";
4
+ exports.SDK_VERSION = "0.6.15";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metergraph",
3
- "version": "0.6.14",
3
+ "version": "0.6.15",
4
4
  "description": "Zero-dependency TypeScript SDK for function-level LLM cost attribution across major LLM providers and frameworks, including OpenAI, Anthropic, Gemini, and Vercel AI SDK.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",