Skip to content

Commit baeb49b

Browse files
fix: Remove obsolete warning about cookie-size
1 parent 65ece16 commit baeb49b

File tree

3 files changed

+0
-26
lines changed

3 files changed

+0
-26
lines changed

V4_MIGRATION_GUIDE.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,6 @@ If you'd like to customize the `user` object to include additional custom claims
235235
## Additional changes
236236

237237
- By default, v4 is edge-compatible and as such there is no longer a `@auth0/nextjs-auth0/edge` export.
238-
- Cookie chunking has been removed
239-
- If the cookie size exceeds the browser limit of 4096 bytes, a warning will be logged
240-
- To store large session data, please use a [custom data store](https://github.com/auth0/nextjs-auth0/tree/main?tab=readme-ov-file#database-sessions) with a SessionStore implementation
241238
- All cookies set by the SDK default to `SameSite=Lax`
242239
- `touchSession` method was removed. The middleware enables rolling sessions by default and can be configured via the [session configuration](https://github.com/auth0/nextjs-auth0/tree/main?tab=readme-ov-file#session-configuration).
243240
- `getAccessToken` can now be called in React Server Components.

src/server/chunked-cookies.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -190,18 +190,6 @@ describe("Chunked Cookie Utils", () => {
190190
expect(reqCookies.delete).toHaveBeenCalledWith(`${name}__4`);
191191
});
192192

193-
it("should log a warning when cookie size exceeds warning threshold", () => {
194-
const name = "warningCookie";
195-
const options = { path: "/" } as CookieOptions;
196-
197-
// Create a value that exceeds the warning threshold (4096 bytes)
198-
const value = "a".repeat(4097);
199-
200-
setChunkedCookie(name, value, options, reqCookies, resCookies);
201-
202-
expect(console.warn).toHaveBeenCalled();
203-
});
204-
205193
describe("getChunkedCookie", () => {
206194
it("should return undefined when cookie does not exist", () => {
207195
const result = getChunkedCookie("nonexistent", reqCookies);

src/server/cookies.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ export { RequestCookies };
127127
const MAX_CHUNK_SIZE = 3500; // Slightly under 4KB
128128
const CHUNK_PREFIX = "__";
129129
const CHUNK_INDEX_REGEX = new RegExp(`${CHUNK_PREFIX}(\\d+)$`);
130-
const COOKIE_SIZE_WARNING_THRESHOLD = 4096;
131130

132131
/**
133132
* Retrieves the index of a cookie based on its name.
@@ -171,8 +170,6 @@ const getAllChunkedCookies = (
171170
* @param options - Options for setting the cookie.
172171
* @param reqCookies - The request cookies object, used to enable read-after-write in the same request for middleware.
173172
* @param resCookies - The response cookies object, used to set the cookies in the response.
174-
*
175-
* @throws {Error} If the cookie size exceeds the warning threshold.
176173
*/
177174
export function setChunkedCookie(
178175
name: string,
@@ -183,14 +180,6 @@ export function setChunkedCookie(
183180
): void {
184181
const valueBytes = new TextEncoder().encode(value).length;
185182

186-
if (valueBytes > COOKIE_SIZE_WARNING_THRESHOLD) {
187-
console.warn(
188-
`The cookie size exceeds ${COOKIE_SIZE_WARNING_THRESHOLD} bytes, which may cause issues in some browsers. ` +
189-
"Consider removing any unnecessary custom claims from the access token or the user profile. " +
190-
"Alternatively, you can use a stateful session implementation to store the session data in a data store."
191-
);
192-
}
193-
194183
// If value fits in a single cookie, set it directly
195184
if (valueBytes <= MAX_CHUNK_SIZE) {
196185
resCookies.set(name, value, options);

0 commit comments

Comments
 (0)