I was wiring up a dashboard page after a long session of getting the project running on Cloudflare Workers. Then I hit an error that made no sense: TypeError: items.map is not a function. .map had always worked. I found a fix within the hour. The cause I wrote down for it was wrong, and it stayed wrong on this page for six months.

Correction, 10 November 2026. The first version of this post said <Await> crashes on Cloudflare Workers, and that the fix is to stop streaming. That was wrong. The crash came from my own loader, it happens the same way in Node, and streaming works on Workers. I rebuilt the case in a small app, ran it in both runtimes, and rewrote the post around what it showed. The list of what I got wrong is at the end.

The pattern that looks perfectly fine

React Router’s <Await> component is designed for streaming. Kick off a slow fetch in your loader without blocking the page render, and the result streams in when it’s ready.

The code is clean:

loader.ts
export async function loader({ context }: Route.LoaderArgs) {
  const activityPromise = db
    .select()
    .from(activity)
    .orderBy(desc(activity.createdAt))
  return { activityPromise } // not awaited, on purpose
}
route.tsx
export default function Dashboard() {
  const { activityPromise } = useLoaderData<typeof loader>()

  return (
    <Suspense fallback={<Skeleton />}>
      <Await resolve={activityPromise}>
        {(items) => <Feed items={items} />}
      </Await>
    </Suspense>
  )
}

This is the shape the React Router docs show. It crashed. I had just spent a long session getting the app onto Cloudflare Workers, so I blamed Workers.

The error that tells you nothing

TypeError: items.map is not a function

That’s it. Nothing in it points at <Await> or mentions Promises. It fails inside your own component, on a value you were sure was an array. On a full page load the server answers with a 500, and the browser shows the route’s error boundary.

What’s actually happening

db.select().from(activity) does not return a Promise. It returns Drizzle’s query builder. The builder has a .then() method, so await works on it, and that is why it feels like a Promise. It isn’t one:

ts
const query = db.select().from(activity)

query instanceof Promise // false
typeof query.then // "function"

It answers to await. That still doesn’t make it a Promise.

Nothing has gone to the database at this point. The query runs when something calls .then(), and await is usually what does.

<Await> does not call .then() on whatever it is given. It asks one question first. This is from React Router 7.14.2, and 7.18.5 and 8.5.1 have the same line:

react-router: Await
if (!(resolve instanceof Promise)) {
  status = 1 /* success */
  promise = Promise.resolve()
  Object.defineProperty(promise, "_tracked", { get: () => true })
  Object.defineProperty(promise, "_data", { get: () => resolve })
}

Anything that is not a Promise counts as a value that is already there. A query builder fails the test, so <Await> hands the builder itself to my render function. items is a PgSelectBase object, and it has no .map. The query never runs: my test counted the calls to the database, and there were none.

The browser gets something different and just as useless. React Router has to send the loader’s data to the browser, and it only streams real Promises. Any other object that isn’t plain data is copied as an object of its own fields. So in the browser items is a plain object with keys like config, session and dialect.

That copy sits in the page for anyone to read. In my test it was 3.6 KB of Drizzle’s internals, table and column names included. The connection string was not in it.

The same in both runtimes

I built the smallest app that has this loader and this component, and changed only what the loader returns.

The loader returns, not awaited What the render function gets Result
A plain array The array Renders
A real Promise The array, once it settles Renders, streamed
A Drizzle query builder The builder on the server, a copy of it in the browser items.map is not a function
The builder with .then((rows) => rows) The array, once it settles Renders, streamed

Every row came out the same three times: under react-router dev in Node, with the production build in Node, and with that build in workerd, the Workers runtime, through wrangler dev. The versions are the ones the app had in May: react-router 7.14.2, React 19.2.5, drizzle-orm 0.45.2 with the Neon HTTP driver, wrangler 4.87.0.

The fix

One line in the loader:

loader.ts
export async function loader({ context }: Route.LoaderArgs) {
  const activityPromise = db
    .select()
    .from(activity)
    .orderBy(desc(activity.createdAt))
    .then((rows) => rows) // a real Promise now
  return { activityPromise }
}

.then() starts the query and returns a real Promise, which is what <Await> and React Router’s serializer both look for. The component stays as it was, and the list streams in. .execute() does the same job, and so does Promise.resolve(query).

If you don’t need the page to arrive before the data, await it instead:

loader.ts
export async function loader({ context }: Route.LoaderArgs) {
  const items = await db
    .select()
    .from(activity)
    .orderBy(desc(activity.createdAt))
  return { items } // plain array, not a Promise
}

That is what the first version of this post told you to do. It works, because await calls .then(). It also gives up streaming, which was the reason to reach for <Await>.

What Cloudflare had to do with it

Nothing, as far as the crash goes. The two things I blamed on Workers were true of something else.

defer() is gone everywhere. I wrote that Workers doesn’t support defer() and that it isn’t in the production bundle. React Router 7 removed defer for every runtime. The export is missing in Node too. You return the Promise from the loader, and that is all.

Streaming works on Workers. I gave the loader a Promise that takes 1.5 seconds. In workerd the skeleton left the server after 46 ms and the rows after 1.5 s, the same as in Node.

There is one place where it doesn’t look that way, and it may be what fooled me. Under wrangler dev, a compressed response is held back until it is complete, and browsers always ask for compression. Chrome got the skeleton and the list together, at 1.5 s. That is a known bug in wrangler’s local server, open since August 2024 and still there in wrangler 4.156.2. The reports say deployed Workers stream normally. I have not measured a deployed Worker myself.

So if you test streaming with wrangler dev and never see your skeleton, that is the local server. It isn’t your code, and it isn’t Workers.

What I got wrong

  • The title. It was “Why <Await> Crashes on Cloudflare Workers”. It crashes the same way in Node.
  • “activityPromise is already a plain array.” A plain array would have rendered. It was the query builder.
  • “<Await> calls .then() on it.” It checks instanceof Promise, and only a real Promise gets waited for.
  • “You add a console.log. The array is there.” With this loader it can’t be. The query never runs.
  • The HydrateFallback advice. In my test it never rendered, on a full load or on a client navigation. It belongs with clientLoader, not here.
  • “<Await> and defer() are Node-only patterns.” There is no such rule.

The right answer was in my own repository the whole time. A commit from the same day adds .then((rows) => rows) to another loader, and its message names the cause. I wrote the post from the commit before it.

The rule

<Await> waits for a real Promise and for nothing else. If what you hand it comes from a query builder, or from any object that only has a .then(), make it a Promise first.

And when an error shows up right after you change platforms, run the same code on the old one before you blame the new one.