Skip to content

Smithy deserialisation error: Unexpected token 'H', "Hello, world!" is not valid JSON #7494

@Inqnuam

Description

@Inqnuam

Checkboxes for prior research

Describe the bug

Since 3.929.0 this simple Lambda streaming response is throwing an error when called with InvokeWithResponseStream cmd

export const handler = awslambda.streamifyResponse(async (event, responseStream, context) => {
  responseStream.setContentType("text/plain");
  responseStream.write("Hello, world!");
  responseStream.end();
});

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/client-lambda@3.929.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v22.21.1

Reproduction Steps

import { Lambda } from "@aws-sdk/client-lambda";

const client = new Lambda();

const res = await client.invokeWithResponseStream({
  FunctionName: "MyFunction",
});

let collectedChunks = Buffer.alloc(0);
for await (const event of res.EventStream!) {
  if (event.PayloadChunk) {
    collectedChunks = Buffer.concat([collectedChunks, event.PayloadChunk.Payload]);
  }
}

Observed Behavior

Unexpected token 'H', "Hello, world!" is not valid JSON
  Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.


HttpResponse {
  statusCode: 200,
  reason: 'OK',
  headers: {
    date: 'Wed, 12 Nov 2025 17:33:17 GMT',
    'content-type': 'application/vnd.amazon.eventstream',
    'transfer-encoding': 'chunked',
    connection: 'keep-alive',
    'x-amzn-requestid': '5dfbde6b-533a-416f-b823-b0f28c5b86c4',
    'x-amz-executed-version': '$LATEST',
    'x-amzn-remapped-content-type': 'text/plain'
  },
  body: 'Hello, world!'
}

Expected Behavior

Should not fail

Possible Solution

Chunks shouldn't be parsed when :event-type is PayloadChunk

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closed-for-stalenessp1This is a high priority issuepotential-regressionMarking this issue as a potential regression to be checked by team member

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions