-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Single Fetch Issues #9324
Comments
After looking at this a bit more, even a simple:
throws the same error:
|
Found the culprit for the first issue. |
I am having the same problem with vercel. Here is my reproduction code. I was wondering where to put installGlobals since it's not a custom server. |
I commented on the Vercel Fork, but I will leave it there in case it may help.
Even the comments themselves acknowledge the presence of certain typing issues. I want to contribute to solve this issue, but i'm not a yet great JS dev myself 😅 . |
Regarding the headers issue - It looks like we may have missed this call out in the docs and only included it in the release notes: https://github.com/remix-run/remix/blob/main/CHANGELOG.md#single-fetch-unstable Single fetch requires using the built-in fetch on node 20, or passing the new option to I’ll get that added to the docs 👍 Update Added to the docs in #9335 |
Just came back here to say the same thing. Rereading the release notes and saw it. |
To recap here, I think this can be closed out?
Please let me know if anything is still outstanding and we can re-open! |
I have enabled Single Fetch in my Remix (with Vite) project. It's working locally, but not on Vercel. I am seeing I am using Node 20. I am calling |
There's an issue for the problem with Vercel at vercel#109 where I posted a workaround. |
Note: I'm still working on the migration/testing, so I kept this title vague for now in case I come across other problems.
Reproduction
https://stackblitz.com/edit/remix-run-remix-tfwhw2?file=app%2Froutes%2F_index.tsx
System Info
Used Package Manager
pnpm
Expected Behavior
Happy to split this out into separate issues, but while migrating to Single Fetch, I've found two issues:
This is in the reproduction, but for the existing use case with
json()
, the application crashes:json
and other utilities now require the headers key to be an instance ofHeaders
.It could be as simple as checking if
result.result.headers instanceof Headers
before callingproxyResponseToResponseStub
, or making the headers argument ofproxyResponseToResponseStub
something likeheaders: Headers | Record<string, string>
, and handling it accordingly.From the Single fetch headers doc:
However, the response stub is potentially undefined (the type in the doc calls this out as well). When is response stub undefined? Having to use a non-null assertion every time doesn't feel right, and typescript throws
The left-hand side of an assignment expression may not be an optional property access.
if trying to do something likeresponse?.status = 200
Actual Behavior
json
would be correct and disallow plain objects for headers or support themThe text was updated successfully, but these errors were encountered: