Kiro icon indicating copy to clipboard operation
Kiro copied to clipboard

An unexpected error occurred, please retry

Open perezjoseph opened this issue 6 months ago • 10 comments

Before opening, please confirm:

Operating System

win32

Kiro Version

0.12.184

Bug Description

Logs: 2026-05-13 21:57:09.272 [info] [SpecSubIntentDetection] classification result {"classification":"specGeneration","local":{"specGeneration":0.9,"taskExecution":0.1},"llm":{"specGeneration":0.9,"taskExecution":0.1},"final":{"specGeneration":0.9,"taskExecution":0.1}} 2026-05-13 21:57:09.281 [info] [Tool agent Action] setup node 2026-05-13 21:57:09.307 [info] [AgentIterator] Invoking agent 2026-05-13 21:57:09.311 [info] [Steering] Populating steering for execution 125533d1-477e-4ef1-bedc-ffbbd71f7a38 2026-05-13 21:57:09.311 [info] [Steering] ExistingFiles: in 125533d1-477e-4ef1-bedc-ffbbd71f7a38 2026-05-13 21:57:09.359 [info] [RemoteToolsDiscovery] Fetching available Remote tools 2026-05-13 21:57:09.359 [info] [SPEC_GRAPH] Tool selection: {"toolCount":24,"toolIds":["user_input","analyze_requirements","execute_pwsh","control_pwsh_process","list_processes","get_process_output","list_directory","read_file","read_files","file_search","grep_search","delete_file","fs_write","fs_append","str_replace","semanticRename","smartRelocate","kiroPowers","createHook","web_fetch","getDiagnostics","readCode","discloseContext","invoke_sub_agent"],"isMergeVibeSpecEnabled":false,"isSpecOrchestratorMode":false,"useFullTools":false} 2026-05-13 21:57:09.633 [error] Failed to stream response chunks function(e,t=!1){return this.sort(((a,r)=>{const i=e(a),n=e(r),o=t?-1:1;return"string"==typeof i&&"string"==typ......s} could not be cloned. 2026-05-13 21:57:09.710 [error] DataCloneError: function(e,t=!1){return this.sort(((a,r)=>{const i=e(a),n=e(r),o=t?-1:1;return"string"==typeof i&&"string"==typ......s} could not be cloned. at new DOMException (node:internal/per_context/domexception:76:18) at structuredClone (node:internal/worker/js_transferable:126:26) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:188076:20) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:188071:34) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:188071:34) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:188071:34) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:188071:34) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:188071:34) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:188071:34) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:188071:34) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:188071:34) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:188071:34) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:188071:34) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:187956:46) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:187956:46) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:187956:46) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:187990:32) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:187956:46) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:187956:46) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:187956:46) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:187956:46) at JsonShapeSerializer._write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:187956:46) at JsonShapeSerializer.write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:187921:28) at HttpInterceptingShapeSerializer.write (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:177689:37) at AwsRestJsonProtocol.serializeRequest (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:177014:22) at async AwsRestJsonProtocol.serializeRequest (c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:188292:26) at async c:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js:174913:24

Steps to Reproduce

1 Open kiro 2 send hello

Expected Behavior

respond

Conversation ID

6492e58a-1ef9-4db9-95d9-de9844201552 6492e58a-1ef9-4db9-95d9-de9844201552 6492e58a-1ef9-4db9-95d9-de9844201552 6492e58a-1ef9-4db9-95d9-de9844201552

Additional Context

No response

perezjoseph avatar May 14 '26 01:05 perezjoseph

🤖 Potential Duplicate Detected

This issue appears to be similar to:

What happens next?

  • ⏰ This issue will be automatically closed in 3 days
  • 🏷️ If this is not a duplicate, you can prevent automatic closure by adding a comment or reacting with 👎 to this message.
  • 💬 Comment on the original issue if you have additional information

Why is this marked as duplicate? Both report 'An unexpected error occurred' with DataCloneError in JsonShapeSerializer on Windows, showing identical error patterns in the serialization process

github-actions[bot] avatar May 14 '26 01:05 github-actions[bot]

kiro-cli analysis:

● Read C:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js (L188056-188085)

  Now I have the full picture. Here's what's happening:
 
  Root Cause
 
  The bug is at line 188076 in the JsonShapeSerializer._write method, inside the isDocumentSchema() branch:                                                                                                           
 
  if (ns3.isDocumentSchema()) {
    if (isObject4) {
      // objects are recursively walked — this path works fine                                                                                                                                                        
      const out2 = Array.isArray(value) ? [] : {};
      for (const k34 in value) {
        const v41 = value[k34];
        // ...
        out2[k34] = this._write(ns3, v41);
      }
      return out2;
    } else {
      return structuredClone(value);  // ← LINE 188076: CRASH HERE
    }
  }
 
  When the serializer encounters a document schema with a non-object value, it calls structuredClone(value). The problem is that a function is reaching this code path — typeof value === "function" is not "object", 
  so it falls into the else branch and structuredClone() throws because functions are not cloneable.
 
  How the function got there
 
  The recursive object walk (for (const k34 in value)) iterates over object properties using for...in. If an object in the payload has a function as a property value (like a .sort() method or helper attached to an 
  array/object), the recursion will eventually call _write with that function. Since typeof function !== "object", isObject4 is false, and it hits structuredClone(function) → boom.
 
  This is a bug in `@aws/codewhisperer-streaming-client`
 
  The serializer doesn't guard against function-typed values before calling structuredClone. It should either:
 
  - Skip functions (return undefined)
  - Or check typeof value === "function" before the structuredClone call
 
  What you can do
 
  1. Clear your Kiro session/conversation state — something in the context being sent to the API contains an object with function properties (possibly from a workspace symbol, a class instance, or tool output that 
  wasn't properly sanitized to plain data).
  2. Restart Kiro — the tainted state may only be in memory.
  3. If it keeps happening, it's likely triggered by a specific file or workspace feature. Try disabling workspace indexing or closing files with complex class exports to isolate the trigger.
 
  This is ultimately a bug the Kiro/AWS team needs to fix — the serializer should handle non-cloneable primitives gracefully rather than crashing.

perezjoseph avatar May 14 '26 02:05 perezjoseph

Thank you for your feedback! 🙏

The duplicate label has been removed and this issue has been sent back for maintainer review.

A maintainer will review this issue shortly.

github-actions[bot] avatar May 14 '26 02:05 github-actions[bot]

kiro-cli patch:

 Write \\?\C:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js
  added 1 line at L187837 in \\?\C:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js
  187837             } else {
  187838+              if (typeof value === "function" || typeof value === "symbol") return undefined;
  187838               return structuredClone(value);
  187839             }

  Multiple occurrences. Let me use more context to target the exact one:
● Read C:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js (L188062-188076)
● Write \\?\C:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js
  added 1 line at L188062 in \\?\C:\Users\Joseph\AppData\Local\Programs\Kiro\resources\app\extensions\kiro.kiro-agent\dist\extension.js
  188062           if (ns3.isDocumentSchema()) {
  188063             if (isObject4) {
  188064               const out2 = Array.isArray(value) ? [] : {};
  188065               for (const k34 in value) {
  188066                 const v41 = value[k34];
  188067                 if (v41 instanceof NumericValue) {
  188068                   this.useReplacer = true;
  188069                   out2[k34] = v41;
  188070                 } else {
  188071                   out2[k34] = this._write(ns3, v41);
  188072                 }
  188073               }
  188074               return out2;
  188075             } else {
  188076+              if (typeof value === "function" || typeof value === "symbol") return undefined;
  188076               return structuredClone(value);
  188077             }
  188078           }

It works now

perezjoseph avatar May 14 '26 02:05 perezjoseph

more of the error:

 2026-05-13 21:49:39.378 [error] Failed to stream response chunks function(e,t=!1){return this.sort(((a,r)=>{const i=e(a),n=e(r),o=t?-1:1;return"string"==typeof i&&"string"==typ...<omitted>...s} could not be cloned.

perezjoseph avatar May 14 '26 02:05 perezjoseph

This change also fixes the issue:

  188062           if (ns3.isDocumentSchema()) {
  188063             if (isObject4) {
  188064               const out2 = Array.isArray(value) ? [] : {};
  188065               for (const k34 in value) {
  188066+                if (!Object.prototype.hasOwnProperty.call(value, k34)) continue;
  188066                 const v41 = value[k34];
  188067-                if (typeof v41 === "function") { console.warn("[KiroPatch] Function found at key:", k34, "on object with keys:", Object.keys(value), "parent constructor:", value?.constructor?.name);       
  188068                 if (v41 instanceof NumericValue) {
  188069                   this.useReplacer = true;
  188070                   out2[k34] = v41;
  188071                 } else {
  188072                   out2[k34] = this._write(ns3, v41);
  188073                 }
  188074               }
  188075               return out2;

perezjoseph avatar May 14 '26 03:05 perezjoseph

I think this explanation makes sense:

 Something in the Kiro runtime adds sortBy as an enumerable method to Array.prototype:                                                                                                               
 
  Array.prototype.sortBy = function(e, t=!1) { return this.sort(...), this }                                                                                                                          
 
  This is a prototype pollution problem. When you add an enumerable property to Array.prototype, every array in the entire process inherits it. Most code is unaffected because Object.keys(),        
  Array.forEach(), and JSON.stringify() only touch own properties.
 
  But the AWS SDK's serializer uses for...in:
 
  for (const k34 in value) {
    // iterates own + inherited enumerable properties
  }
 
  for...in walks the entire prototype chain. So for any array ["a", "b"]:
 
  - "0" → own ✓
  - "1" → own ✓
  - "sortBy" → inherited from Array.prototype ✓ (enumerable!)
 
  The serializer then tries to serialize the sortBy function as if it were data. When it reaches the structuredClone fallback for non-object values, it crashes because functions aren't cloneable.   
 

perezjoseph avatar May 14 '26 03:05 perezjoseph

I think I found it:

  - Root cause: SARIF Viewer pollutes Array.prototype.sortBy (enumerable)
  - Effect: AWS SDK serializer iterates inherited sortBy via for...in, tries to structuredClone a function, crashes                                                                                                   
  - Fix: Disable/uninstall the SARIF Viewer extension                                                                                                                                                                 

The extensions

perezjoseph avatar May 14 '26 03:05 perezjoseph

Thank you. This was helpful.

TLDR for anyone who stumbles on this: Disable SARIF Viewer Extension

Or just check extensions in general.

arpit-dlv avatar Jun 18 '26 12:06 arpit-dlv

Closing this issue as it was reported against an older version of Kiro (v0.x or early v1.x) and has had no activity in several months.

Kiro has shipped significant improvements since these versions, including stability fixes, new features, and major changes across v1.0, v1.1, v2.x, and the current v2.23.x releases. The behavior described here may already be resolved.

If this is still affecting you on the latest version, please open a new issue at https://github.com/kirodotdev/Kiro/issues/new with your current version (kiro-cli --version or Help > About in the IDE), your OS, and steps to reproduce. The latest version is available at https://kiro.dev/downloads/ or via kiro-cli update.

Thank you for taking the time to report this.

AnilMaktala avatar Sep 24 '26 13:09 AnilMaktala