Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Could not convert argument of type symbol to string when setting headers with Headers object in Node.js v22.2.0 #53069

Closed
elhaddajiOtmane opened this issue May 20, 2024 · 2 comments
Labels
question Issues that look for answers.

Comments

@elhaddajiOtmane
Copy link

Version

v22.2.0

Platform

Microsoft Windows NT 10.0.22631.0 x64

Subsystem

idk :undici package (dependency used by Next.js)

What steps will reproduce the bug?

Create a new Next.js project using the latest version (as of writing, it's Next.js 13.2.4).
In one of the pages , import the Headers object from undici and try to set headers,
let headers = new Headers();
headers.set('Access-Control-Allow-Credentials', true);
headers.set('Access-Control-Allow-Origin', '*');
headers.set('x-auth-token',' process.env.EXAMPLE.TOKEN');

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

The issue reproduces consistently when running the above steps with Node.js version 22.2.0.

What is the expected behavior? Why is that the expected behavior?

The expected behavior is for the Headers object to correctly accept and set the provided header key-value pairs without throwing any errors. This is the expected behavior because the Headers object should handle string values for both header keys and values according to the documentation and specifications.

What do you see instead?

TypeError: Could not convert argument of type symbol to string.
at webidl.converters.DOMString (node:internal/deps/undici/undici:1977:15)
at webidl.converters.ByteString (node:internal/deps/undici/undici:1982:35)
at Object.record<ByteString, ByteString> (node:internal/deps/undici/undici:1894:30)
at webidl.converters.HeadersInit (node:internal/deps/undici/undici:3424:67)
at new Headers (node:internal/deps/undici/undici:3278:36)

Additional information

"undici": "5.23.0",

@elhaddajiOtmane
Copy link
Author

Everything is working fine with the Headers object when using Node.js 20.1.0

@RedYetiDev RedYetiDev added the question Issues that look for answers. label May 20, 2024
@KhafraDev
Copy link
Member

Fixed in #53034

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issues that look for answers.
Projects
None yet
Development

No branches or pull requests

3 participants