Transferring huge buffer
I'm using tRPC with superjson serializer in an Electron app. I have a router querry that loads an png image, parses it with
sharp
and sends it as a buffer to client to render inside canvas. For larger files (62MB) I'm getting a Invalid array length
error from superjson though. Can you think of a way to work around this issue?Solution:Jump to solution
I've implemented it by returning the url to fetch from my mutation and added
``ts
protocol.handle('local-raw', request =>
net.fetch(
file:///${request.url.slice('local-raw://'.length)}`)
);...3 Replies
are you sending the buffer or encoding it in some way?
as a int8array or uint8clampedarray?
int8array
Solution
I've implemented it by returning the url to fetch from my mutation and added
to
app.whenReady
so the buffer doesn't have to go through tRPC