Haaxor1689H
tRPC3y ago
6 replies
Haaxor1689

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
I've implemented it by returning the url to fetch from my mutation and added
protocol.handle('local-raw', request =>
  net.fetch(`file:///${request.url.slice('local-raw://'.length)}`)
);

to app.whenReady so the buffer doesn't have to go through tRPC
Was this page helpful?