schettn
schettn
Explore posts from servers
HHono
Created by schettn on 3/5/2025 in #help
How to implement renderToPipeableStream with the streaming API?
I want to SSR stream react with hono (nodejs) https://react.dev/reference/react-dom/server/renderToPipeableStream I got it working using a promise based approach:
return await new Promise<Response>((resolve, reject) => {
const {pipe} = reactServer.renderToPipeableStream(
<App />,
{
bootstrapModules: ['/__pylon/static/app.js'],
bootstrapScriptContent: `window.__PYLON_DATA__ = ${JSON.stringify(
{
pageProps: pageProps,
cacheSnapshot: cacheSnapshot
}
)}`,
onShellReady: async () => {
c.header('Content-Type', 'text/html')

const passThrough = new PassThrough()

pipe(passThrough)

resolve(c.body(Readable.toWeb(passThrough) as any))
},
onShellError: async error => {
reject(error)
}
}
)
})
return await new Promise<Response>((resolve, reject) => {
const {pipe} = reactServer.renderToPipeableStream(
<App />,
{
bootstrapModules: ['/__pylon/static/app.js'],
bootstrapScriptContent: `window.__PYLON_DATA__ = ${JSON.stringify(
{
pageProps: pageProps,
cacheSnapshot: cacheSnapshot
}
)}`,
onShellReady: async () => {
c.header('Content-Type', 'text/html')

const passThrough = new PassThrough()

pipe(passThrough)

resolve(c.body(Readable.toWeb(passThrough) as any))
},
onShellError: async error => {
reject(error)
}
}
)
})
15 replies
HHono
Created by schettn on 3/5/2025 in #help
How to implement renderToPipeableStream with the streaming API?
Okay thanks, so i cannot use the streaming api.
15 replies
HHono
Created by schettn on 3/5/2025 in #help
How to implement renderToPipeableStream with the streaming API?
"However, when the callback function is executed, the stream has already started, so it cannot be overwritten."
15 replies
HHono
Created by schettn on 3/5/2025 in #help
How to implement renderToPipeableStream with the streaming API?
When does the stream open? When you first put data inside or earlier? onShellReady and onShellError are exclusive.
15 replies
HHono
Created by schettn on 3/5/2025 in #help
How to implement renderToPipeableStream with the streaming API?
React server has a renderToReadableStream but it is not supported in node enviroments.
15 replies
PPrisma
Created by schettn on 11/27/2024 in #help-and-questions
`isNot: null` filter on relation does not work
Right?
8 replies
PPrisma
Created by schettn on 11/27/2024 in #help-and-questions
`isNot: null` filter on relation does not work
The issue is, although no routes have associated region, ‘routesData’ contains all routes. I thought that by providing ‘isNot: null’ to the relations, it will exclude all routes that have no region. In my case all of them. So I expect an empty array. The console log shows the relation of the first route which is null, thus this route should not be there.
8 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
The root cause is that Prisma Studio loads every record of relations into its RecordStore
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
No description
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
No description
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
@Nurul I have reverse engineered the issue. Take a look at the following code:
r.select = l.reduce((e, t) => {
console.log(e,t)


if (!t) return e;
if (t.isList && t.isRelation) {
const s = t.getRelationIDFieldName;

e[t.name] = !s || { select: { [s]: !0 } };
} else e[t.name] = !0;
return e;
}, {})
r.select = l.reduce((e, t) => {
console.log(e,t)


if (!t) return e;
if (t.isList && t.isRelation) {
const s = t.getRelationIDFieldName;

e[t.name] = !s || { select: { [s]: !0 } };
} else e[t.name] = !0;
return e;
}, {})
prisma studio used this to calculate the select. Normally it would use getRelationIDFieldName to get the primary keys of the relation. In my case i use compound primary keys like @@id([tripId, stopId, stopSequence, gtfsImportId]). With compound keys the getRelationIDFieldName returns null, it sets the relation to true instead using only the primary keys of the relation.
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
Is it a design decision that currently all relation data is fetched, or is it a "bug"? Because if the relations are only needed for the relation counts then a simple rewrite to this would do the trick:
const res = await client.gTFSImport.findMany({
select: {
_count: {
select: {
CalendarDate: true,
agencies: true,
calendars: true,
routes: true,
stopTimes: true,
stops: true,
tourismRegions: true,
trips: true,
},
},
},
skip: 0,
take: 100,
});
const res = await client.gTFSImport.findMany({
select: {
_count: {
select: {
CalendarDate: true,
agencies: true,
calendars: true,
routes: true,
stopTimes: true,
stops: true,
tourismRegions: true,
trips: true,
},
},
},
skip: 0,
take: 100,
});
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
Thanks
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
I think that prisma studio runs into memory problem when processing this large amout of data client side. So its not directly related to the response time. I calculated the total size of the query that is performed by Prisma Studio for the GTFSImport table (with relations):
Time taken: 8059ms
Size of res: 181.3017292022705 MB
Time taken: 8059ms
Size of res: 181.3017292022705 MB
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
No description
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
How is this possible? The "Fields" filter only hides the UI elements
22 replies
PPrisma
Created by schettn on 11/26/2024 in #help-and-questions
Prisma Studio crashes with large databases
Querying only the stoptimes takes about 7 seconds. But the StopTimes works well in Prisma Studio
22 replies