Comments (10)
I can somewhat workaround this by changing my server-side object declaration to match what client renders, i.e.
{
name: 'Hello, World!',
'@context': 'https://schema.org',
},
But this is finicky and problematic because I have ESLint rule that auto sorts properties alphabetically.
from remix.
This looks like it's coming from internal JSON.parse
behavior that must order numeric object keys:
@jacob-ebey What do you think about prefixing those with _
or something in turbo-stream to make them non-numeric?
from remix.
I think in my case it is the properties that start with @
.
from remix.
It's not related to the name of the key. It's due to the reuse of a name
property that was previously used. turbo-stream
dedupes keys and values to keep the payload minimal, and it tracks them basically with an incrementing integer. When you return something like the following, the first occurrence of name
gets assigned a lower integer than @context
and then the second occurrence of name
re-uses the earlier/lower id.
export const loader = () => {
return {
meta: [
{
name: 'description',
// ^ `name` here gets assigned a lower numeric id since it's earlier
content: 'Welcome to Remix!',
},
{
'script:ld+json': [
{
'@context': 'https://schema.org',
// ^ `@context` here gets assigned a higher numeric id since it's later
name: 'Hello, World!',
// ^ `name` here reuses the earlier (lower) numeric id
},
],
},
],
};
};
This results in the problem I described above where we stringify an object with a higher numeric key, followed by a lower numeric key - and JSON.parse
re-orders them when parsing, moving name
before @context
from remix.
I believe I have addressed this with [email protected]. I can no longer reproduce it in the stackblitz: https://stackblitz.com/edit/remix-run-remix-eliwev?file=package.json
from remix.
I think the serialization is still unstable in a slightly different manner - just not surfacing this specific meta/json+ld issue. Here's a simplified repro on 2.2.3
: https://stackblitz.com/edit/remix-run-remix-bbrwkg?file=app%2Froutes%2F_index.tsx
from remix.
Added some better tests and addressed it here: jacob-ebey/turbo-stream#45
from remix.
👍 Awesome - the above stackblitz is fixed with [email protected]
via the solution in #9421 (comment).
from remix.
[email protected]
will be the default version in Remix 2.11.2
(currently in prerelease, stable release later this week) so you won't need your own turbo-stream
dependency in your package.json
once upgrading 👍
from remix.
Thank you!
from remix.
Related Issues (20)
- Dev server not working properly on Safari browser HOT 4
- Top Suspense fallback not work HOT 8
- request.json() / request.text() doesn't resolve when "Content-Type" header is "application/json" HOT 7
- getInternalRouterError for missing POST endpoint instead of 405 Method Not Allowed HOT 9
- Loader function not executed after redirect to same url with different search params after update to remix v2 HOT 2
- Test setup/utils files importing server module gives: Server-only module referenced by client HOT 2
- Turbo responses are not compressed by Cloudflare
- cannot use non-standard HTTP methods within action HOT 4
- clientLoader hydration message shows in SPA that doesn't use clientLoader HOT 2
- Remix Serve calls installGlobals() HOT 3
- single-fetch `useLoaderData()` evaluates to `null` when redirecting to same URL when `shouldRevalidate` returns false HOT 2
- Error code: SIGILL, Chrome 128 (Aw, snap! Chrome error) Dev mode HOT 7
- Client builds are not deterministic in some cases HOT 1
- Failing Remix-run build on Vercel HOT 7
- docs - typo in createSessionStorage description
- cannot return HTTP 304 using unstable_singleFetch HOT 9
- [docs] $contactId vs $id inconsistency in website tutorial HOT 6
- Upgrade to v2.12.0 causing Vite "module externalized" warnings HOT 1
- `unstable_data` with `LoaderFunction` using `unstable_singleFetch` breaks type inference HOT 1
- Database connection error when using Prisma with Vite and SQL Server (PrismaClientInitializationError)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remix.