@juspay/neurolink 12.0.0 → 12.0.1

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.
@@ -20,6 +20,23 @@
20
20
  * nothing about this behaves exactly as it did before.
21
21
  */
22
22
  const STREAM_CANCEL = Symbol.for("neurolink.streamCancel");
23
+ /**
24
+ * Swallow a rejection from a thenable teardown result.
25
+ *
26
+ * An unhandled rejection **terminates the process** — a caller doing everything
27
+ * right still dies, with the stack pointing at library internals it never
28
+ * called. Teardown runs after the consumer has stopped listening, so there is
29
+ * nobody left to hand the error to; dropping it is the only correct outcome,
30
+ * and dropping it deliberately is what keeps it from becoming fatal.
31
+ */
32
+ function suppressRejection(result) {
33
+ if (result !== null &&
34
+ typeof result === "object" &&
35
+ typeof result.then === "function" &&
36
+ typeof result.catch === "function") {
37
+ void result.catch(() => { });
38
+ }
39
+ }
23
40
  /**
24
41
  * Register `cancel` as `stream`'s teardown hook and return the same object.
25
42
  *
@@ -59,7 +76,10 @@ export function cancelStream(stream) {
59
76
  if (typeof hook !== "function") {
60
77
  return;
61
78
  }
62
- hook();
79
+ // `attachStreamCancel` types the hook as `() => void`, but nothing stops a
80
+ // caller registering an `async` function — whose rejection would otherwise
81
+ // be unhandled, and therefore fatal to the process.
82
+ suppressRejection(hook());
63
83
  }
64
84
  catch {
65
85
  // Teardown is best-effort by definition.
@@ -73,16 +93,15 @@ export function cancelStream(stream) {
73
93
  * avoid. The call still propagates whenever the iterator can act on it.
74
94
  */
75
95
  export function releaseIterator(iterator) {
76
- if (typeof iterator.return !== "function") {
77
- return;
78
- }
79
96
  try {
80
- const result = iterator.return(undefined);
81
- if (result &&
82
- typeof result.catch === "function" &&
83
- typeof result.then === "function") {
84
- void result.catch(() => { });
97
+ // Read the method inside the try, for the same reason `cancelStream` does:
98
+ // `iterator` is whatever an upstream handed us, and a Proxy trap or a
99
+ // throwing getter turns a property access into arbitrary user code.
100
+ const release = iterator.return;
101
+ if (typeof release !== "function") {
102
+ return;
85
103
  }
104
+ suppressRejection(release.call(iterator, undefined));
86
105
  }
87
106
  catch {
88
107
  // Best-effort, as above.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "12.0.0",
3
+ "version": "12.0.1",
4
4
  "packageManager": "pnpm@10.15.1",
5
5
  "description": "TypeScript AI SDK with 24+ LLM providers behind one consistent API. MCP-native (connect any MCP server), voice TTS/STT/realtime, RAG, agents, memory, context compaction. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · DeepSeek · NVIDIA NIM and more.",
6
6
  "author": {