Skip to content

Commit

Permalink
Do not serialize uint8array
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Candeia <[email protected]>
  • Loading branch information
mcandeia committed Oct 19, 2024
1 parent c8ac1ab commit 0901f51
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/actors/proxyutil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ export const createHttpInvoker = <
if (resp.status === 204) {
return;
}
if (
resp.headers.get("content-type")?.includes("application/octet-stream")
) {
return new Uint8Array(await resp.arrayBuffer());
}
return resp.json();
},
};
Expand Down
9 changes: 9 additions & 0 deletions src/actors/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,15 @@ export class ActorRuntime {
if (typeof res === "undefined") {
return new Response(null, { status: 204 });
}
if (res instanceof Uint8Array) {
return new Response(res, {
headers: {
"content-type": "application/octet-stream",
"content-length": `${res.length}`,
},
status: 200,
});
}
return Response.json(res);
} catch (err) {
if (err instanceof ActorError) {
Expand Down

0 comments on commit 0901f51

Please sign in to comment.