edge-runtime
edge-runtime copied to clipboard
console.log()'ging a response throws
Logging a response throws, eg console.log(new Response("yes"))
throws an error.
Reproduction
First way to reproduce (longer)
- Create an Edge API Route
- Fetch anything
- Log the response
import type { NextRequest } from "next/server";
export const config = {
runtime: "experimental-edge",
};
export default async function handler(req: NextRequest) {
await fetch("https://example.com").then((res) => {
console.log(res); // this throws, commenting out this line makes it work
return res.text();
});
return new Response("yea");
}
Second way to reproduce (shorter)
import type { NextRequest } from "next/server";
export const config = {
runtime: "experimental-edge",
};
export default async function handler(req: NextRequest) {
const response = new Response("yea");
console.log(response); // this throws, commenting out this line makes it work
return response;
}
Error
Both of these throw
error - Error [TypeError]: Cannot delete property 'Symbol(set-cookie)' of #<HeadersList2>
at <unknown> (evalmachine.<anonymous>:114:24)
at Array.forEach (<anonymous>)
at formatValue (evalmachine.<anonymous>:110:19)
at formatProperty (evalmachine.<anonymous>:181:19)
at <unknown> (evalmachine.<anonymous>:155:114)
at Array.map (<anonymous>)
at formatValue (evalmachine.<anonymous>:155:101)
at formatProperty (evalmachine.<anonymous>:181:19)
at <unknown> (evalmachine.<anonymous>:155:114)
at Array.map (<anonymous>)
I believe it's this line which ends up throwing https://github.com/vercel/edge-runtime/blob/e89ddce0566537e64c282229b0a2df63ea0dbe6d/packages/format/src/index.ts#L103