Skip to content

getCookies() throws error when cookie header is an empty string  #7320

Open

Description

@0xMurage

Describe the bug

Steps to Reproduce

import { getCookies } from 'jsr:@std/http@1.1.3/cookie';

const headers = new Headers({ cookie: '' });
getCookies(headers); //fails
  1. Execute the file using Deno (deno run demo.ts).
  2. See error.

Expected behavior

getCookies() should gracefully handle empty cookie strings and return an empty object {} instead of throwing an exception.

Currently only null value is being checked.

if (cookie !== null) {

Actual behavior

error: Uncaught (in promise) SyntaxError: Cookie cannot start with '='
        throw new SyntaxError("Cookie cannot start with '='");

error thrown at

throw new SyntaxError("Cookie cannot start with '='");

Environment

  • OS: Linux
  • deno version: 2.9.2
  • std version: 1.1.3

Activity

  1. changed the title [-]`getCookies()` throws SyntaxError when Headers contains an empty cookie string (cookie: '')[/-] [+]`getCookies()` throws error when cookie header is an empty string [/+] on Sep 14, 2026
  2. dennisimoo commented on Sep 23, 2026

    @dennisimoo
    Contributor

    I’ll add a focused fix and regression tests for empty and whitespace-only headers, while keeping malformed nonempty cookies rejected. AI-assisted with Codex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions