Skip to content

fix(server + client): Post release httpBatchStreamLink issues - #4481

Merged
KATT merged 14 commits into
mainfrom
fix/batch-streaming-post-release-fixes
Jun 4, 2023
Merged

KATT merged 14 commits into
mainfrom
fix/batch-streaming-post-release-fixes

Conversation

@Sheraff

@Sheraff Sheraff commented Jun 3, 2023 •

Copy link
Copy Markdown
Contributor

🎯 Changes

TextDecoder doesn't exist in the global scope for React Native #4347 (comment)

Commit: f877b24

  • Added a textDecoder option to the instantiation of httpBatchStreamLink:

    unstable_httpBatchStreamLink({
      url: 'http://localhost:3000',
      textDecoder: new TextDecoder(),
      // ^? textDecoder: { decode: (input: Uint8Array) => string }
    })

    This is not required to be provided, but allows for overriding the native API (like is already done for fetch).

  • The TextDecoder API is now accessed from the global scope global.TextDecoder

    ❓️❓️Which is the most supported one? global or globalThis? ❓️❓️

  • The TextDecoder API is now accessed from inside a function, so should not crash the client, even if it wasn't tree-shaken out*

on Next.js 12, httpBatchStreamLink works like a regular httpBatchLink

Commit: cbe8398

On some servers, "pushing data to a stream" is not sufficient to "stream a response". We might have several cases like this (different adapters, different uses...), but so far I've only encountered 1.

On Next.js <13 and on Express with a compress() link, the response isn't streamed because it's being gzipped. Both of these use the nodeHTTPRequestHandler and in both of these cases, there is a method added to the res object: res.flush().

  • add optional flush key on NodeHTTPResponse type (which is accurate: sometimes it's there sometimes not)
  • optional chaining call of .flush() on every .write() for a streamed response
  • rearrange adapters so that the "setting up a stream" phase happens in onHead instead of first onChunk. This was not really necessary for this fix, but seems more correct and might make future similar fixes easier.

the new version introduced a type error about a missing eagerGeneration key #4347 (comment)

Commit: 4e8c260

Version 10.29 added a new eagerGeneration key in the arguments passed to ResponseMetaFn to indicate that this function is being called before knowing the response body. This key is always provided by resolveHTTPResponse but some people seem to have been using the type externally. So we're making it optional.

✅ Checklist

  • I have followed the steps listed in the Contributing guide.
  • If necessary, I have added documentation related to the changes made.
  • I have added or updated the tests related to the changes made.

@Sheraff
Sheraff requested review from a team as code owners June 3, 2023 19:58
@vercel

vercel Bot commented Jun 3, 2023 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-prisma-starter ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 4, 2023 2:01pm
og-image ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 4, 2023 2:01pm
www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 4, 2023 2:01pm

@github-actions github-actions Bot added @trpc/client @trpc/server 🕸 www Stuff to do with the website (`/www` folder) labels Jun 3, 2023
@kamilogorek

Copy link
Copy Markdown
Contributor

❓️❓️Which is the most supported one? global or globalThis? ❓️❓️

We use globalThis in other places.

@KATT
KATT merged commit d4bd1a9 into main Jun 4, 2023
@KATT
KATT deleted the fix/batch-streaming-post-release-fixes branch June 4, 2023 15:00
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 4, 2023

This branch was successfully deployed

4 active deployments
Preview – www — 9efac313 Deployed Jun 4, 2023 by vercel[bot]
Preview – todomvc — 9efac313 Deployed Jun 4, 2023 by vercel[bot]
Preview – next-prisma-starter — 9efac313 Deployed Jun 4, 2023 by vercel[bot]
Preview – og-image — 9efac313 Deployed Jun 4, 2023 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

♻️ autoupdate @trpc/client @trpc/server 🕸 www Stuff to do with the website (`/www` folder)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants