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

fix: split cookie headers #1452

Merged
merged 21 commits into from
Jul 19, 2023
Merged

fix: split cookie headers #1452

merged 21 commits into from
Jul 19, 2023

Conversation

Hebilicious
Copy link
Member

@Hebilicious Hebilicious commented Jul 17, 2023

  • feat: handler cookie headers for Response
  • chore: flag unhandled cookies

πŸ”— Linked issue

Closes #989
Fix #988

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Continuing the work done by @oleghalin and applying it more generally to every presets that needs it.
Note that the culprit for this would be unenv, but fixing this in Nitro allows us to not add any dependency to unenv.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@Hebilicious Hebilicious changed the title split cookie headers feat: split cookie headers Jul 17, 2023
@Hebilicious Hebilicious requested a review from pi0 July 17, 2023 11:23
@Hebilicious Hebilicious added the enhancement New feature or request label Jul 17, 2023
@codecov
Copy link

codecov bot commented Jul 17, 2023

Codecov Report

Merging #1452 (f1ffb74) into main (e87e2ba) will decrease coverage by 0.09%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #1452      +/-   ##
==========================================
- Coverage   76.17%   76.09%   -0.09%     
==========================================
  Files          73       73              
  Lines        7437     7428       -9     
  Branches      728      727       -1     
==========================================
- Hits         5665     5652      -13     
- Misses       1771     1774       +3     
- Partials        1        2       +1     

see 2 files with indirect coverage changes

@pi0
Copy link
Member

pi0 commented Jul 17, 2023

Thanks. I think we can add fix to a wrapper of localFetch util directly so that entries using it already have fix

@Hebilicious
Copy link
Member Author

Thanks. I think we can add fix to a wrapper of localFetch util directly so that entries using it already have fix

We can do it like this :

  function normalizedHeaders(fetch: typeof globalThis.fetch) {
    return async (...args: Parameters<typeof fetch>) => {
      const r = await fetch(...args);
      return new Response(r.body, {
        headers: normalizeOutgoingHeaders(r.headers),
        status: r.status,
        statusText: r.statusText,
      });
    };
  }

  // Create local fetch callers
  const localCall = createCall(toNodeListener(h3App) as any);
  const localFetch = normalizedHeaders(
    createLocalFetch(localCall, globalThis.fetch)
  );

I'm worried about the possible impact of changing $fetch for Nuxt, or something else besides the preset runtimes.
If the goal is to DRY we can add a localNormalizedHeadersFetch and call this in the presets.
I think I'll let you decide.

@pi0 pi0 removed the ready label Jul 17, 2023
@pi0
Copy link
Member

pi0 commented Jul 17, 2023

Yes, i still think wrapper method would be better idea.

@pi0 pi0 changed the title feat: split cookie headers fix: split cookie headers for worker presets Jul 17, 2023
Copy link
Member Author

Is there any reason why cloudflare, lagon, denos, netlify-edge, service worker and vercel-edge presets are using localCall ? They are all returning a Response.

@pi0
Copy link
Member

pi0 commented Jul 17, 2023

Is there any reason why cloudflare, lagon, denos, netlify-edge, service worker and vercel-edge presets are using localCall ? They are all returning a Response.

They need to be upgraded to localFetch. free to include fix in same PR (basically i made that refactor back in time for other presets to prepare for this unified fix :D)

src/runtime/app.ts Outdated Show resolved Hide resolved
src/runtime/utils.ts Outdated Show resolved Hide resolved
@pi0 pi0 changed the title fix: split cookie headers for worker presets fix: split cookie headers Jul 17, 2023
@Hebilicious
Copy link
Member Author

@danielroe tagging you for the Azure changes

@pi0
Copy link
Member

pi0 commented Jul 19, 2023

Added some refactors and tests. While making tests discovered some issues. Netlify is fixed but we have Node (#1462) and Bun (#1461) to be fixed.

Probably on nitro-deploys with edge channel we can E2E test better on tests to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set Cookie merged into one header (Cloudflare Workers)
2 participants