Haaxor1689
Haaxor16898mo ago

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 ``ts protocol.handle('local-raw', request => net.fetch(file:///${request.url.slice('local-raw://'.length)}`) );...
Jump to solution
3 Replies
SebasPtsch
SebasPtsch8mo ago
are you sending the buffer or encoding it in some way? as a int8array or uint8clampedarray?
Haaxor1689
Haaxor16898mo ago
int8array
Solution
Haaxor1689
Haaxor16898mo ago
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)}`)
);
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