Hono 4.13.20 and AWS Lambda Adapters: Async Provider Isolation, Faster JSONParsed Types, and Clean 204 ResponsesNote · digest for November 23
Isometric architectural diagram of request routing through Hono and AWS Lambda adapters
Note3 sections≈ 5 min

Hono 4.13.20 and AWS Lambda Adapters: Async Provider Isolation, Faster JSONParsed Types, and Clean 204 Responses

Tests pass locally, then production turns mysterious. A delete endpoint returns an empty 204 status, yet CloudFront rejects it with 502 Bad Gateway. A CSV export with non-ASCII text opens as garbled characters in Excel even though the byte-order mark is right there. Painfully familiar.

A trio of patches released on November 22, 2026 fixes these quiet failures: core Hono v4.13.20 alongside adapters @hono/aws-lambda 1.0.2 and @hono/lambda-edge 1.0.2. Hono adds no new APIs here, but cleans up rough edges across server JSX, TypeScript types, HTTP headers, and AWS.

Server JSX and TypeScript types without surprises

A sneaky bug hid in async JSX: during parallel or nested rendering, a component after an await could read context from a sibling or parent Provider. In 4.13.20, each Provider gets an isolated store via AsyncLocalStorage wherever the runtime supports it (Node.js, Bun, Deno, and Cloudflare Workers with nodejs_compat). Meanwhile, hono/jsx/dom restored the useActionState fixes that were reverted in the previous release.

A second fix speeds up TypeScript. Hono's JSONParsed type for RPC clients computes what a server object looks like after JSON.stringify and JSON.parse. In 4.13.19, it bloated type instantiations, slowed down tsc, and turned optional fields like nickname?: string into | undefined, breaking exactOptionalPropertyTypes. Now properties resolve lazily without excessive recursion, and optional fields stay plain optional.

import { createContext, useContext } from 'hono/jsx'
import type { JSONParsed } from 'hono/utils/types'

const TenantContext = createContext('default')

// After await, the component reads its own Provider instead of a sibling
const AsyncBanner = async () => {
  await Promise.resolve()
  return <p>Тенант: {useContext(TenantContext)}</p>
}

// Optional field does not turn into string | undefined
type UserDto = { id: number; nickname?: string }
type ParsedUser = JSONParsed<UserDto>

The helper/websocket module was also decoupled from DOM types, so server projects without lib: ["DOM"] in tsconfig.json compile cleanly without workarounds.

HTTP edge cases, compression, and AbortSignal pitfalls

In hono/client, deepMerge had a trap. It merged client and request options as plain objects, corrupting class instances like AbortSignal when signals were passed at both levels. Now only plain objects merge deeply, while class instances replace wholesale.

Two HTTP spec details were tightened as well. The compress middleware used to keep the uncompressed Content-Length on HEAD requests while GET served a compressed body, violating RFC 9110. Now HEAD sends matching Content-Encoding and weak ETag headers without the broken length. Also, the cookie parser stopped turning a lone " into an empty string "": surrounding quotes are stripped only when the value is at least two characters long.

AWS Lambda and Lambda@Edge: 204 responses, BOM, and headers

Why did c.body(null, 204) work on a laptop and fail with 502 in the cloud? Lambda@Edge (functions running at CloudFront CDN edge nodes) strictly validates viewer-request responses. By spec, 204 No Content has no body, yet the adapter attached a body field, causing CloudFront to return 502 Bad Gateway. In @hono/lambda-edge 1.0.2, 204 responses return only status and headers.

A similar issue hit UTF-8 BOM (\uFEFF), the three-byte marker at the start of text that Windows Excel needs to open UTF-8 CSVs without garbled characters. Standard Response.text() silently strips the BOM. Both adapters and core 4.13.20 now decode non-Base64 text using new TextDecoder('utf-8', { ignoreBOM: true }), keeping the marker intact.

import { Hono } from 'hono'
import { handle } from '@hono/lambda-edge'

const app = new Hono()

// In 1.0.2 the adapter omits the body field so CloudFront will not return 502
app.delete('/items/:id', (c) => c.body(null, 204))

// Leading UTF-8 BOM is preserved for opening CSVs in Excel
app.get('/report.csv', (c) => {
  c.header('Content-Type', 'text/csv; charset=utf-8')
  return c.text('\uFEFFid,name\n1,Заказ\n')
})

export const handler = handle(app)

In @hono/aws-lambda 1.0.2, a gap for API Gateway v2 (AWS's lightweight HTTP API) and Function URLs was also closed: EventV2Processor.getHeaders passed values straight into headers.set(), so any non-ASCII character threw a TypeError and returned 400 Invalid request. It now runs sanitizeHeaderValue(), matching v1, ALB, and VPC Lattice.

If you install the adapters separately rather than through hono/aws-lambda, update them alongside core: pnpm up hono@^4.13.20 @hono/aws-lambda@^1.0.2 @hono/lambda-edge@^1.0.2. All three patches are backward-compatible and need no code changes.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 7