Skip to content

"cookies is not iterable" error thrown when trying to iterate over a fetch response that contains a Set-Cookie header #46704

Closed
@dtinth

Description

@dtinth

Version

18.14.1

Platform

Darwin dtinth-m1.local 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:30 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8103 arm64

Subsystem

undici

What steps will reproduce the bug?

See: nodejs/undici#1935

How often does it reproduce? Is there a required condition?

See: nodejs/undici#1935
See: sveltejs/kit#9091

What is the expected behavior?

No error

What do you see instead?

 error   cookies is not iterable
  File:
    /Users/dtinth/Projects/contentsgarten/creatorsgarten/src/pages/api/contentsgarten/[action].ts:82:47
  Code:
    81 |     const response = await fetch(backendUrl, {
    > 82 |       method: request.method,
         |                                               ^
      83 |       headers,
      84 |       body: request.body,
      85 |     })
  Stacktrace:
TypeError: cookies is not iterable
    at get [headers map sorted] (node:internal/deps/undici/undici:1844:34)
    at node:internal/deps/undici/undici:1865:43
    at Headers Iterator.next (node:internal/deps/undici/undici:1108:26)
    at Function.from (<anonymous>)

Additional information

The issue nodejs/undici#1935 is already closed because there was a merged PR that fixes the issue nodejs/undici#1936

However, a Node.js version with the fix has not been released yet… So the issue is shifted to Node.js side to release a version of undici with the fix (or rollback the version of undici that adds the regression).

Metadata

Metadata

Assignees

No one assigned

    Labels

    fetchIssues and PRs related to the Fetch API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions