Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Improve uint8array serializing perf" #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/actors/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type { ActorStorage } from "./storage.ts";
import { DenoKvActorStorage } from "./storage/denoKv.ts";
import { S3ActorStorage } from "./storage/s3.ts";
import { EVENT_STREAM_RESPONSE_HEADER } from "./stream.ts";
import { serializeUint8Array } from "./util/buffers.ts";
import { isUpgrade, makeWebSocket } from "./util/channels/channel.ts";
import {
type ServerSentEventMessage,
Expand Down Expand Up @@ -191,7 +190,7 @@ export class ActorRuntime {
for await (const content of res) {
controller.enqueue({
data: encodeURIComponent(
JSON.stringify(content, serializeUint8Array),
JSON.stringify(content),
),
id: Date.now().toString(),
event: "message",
Expand Down
5 changes: 1 addition & 4 deletions src/actors/stream.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { deserializeUint8Array } from "./util/buffers.ts";

export const EVENT_STREAM_RESPONSE_HEADER: string = "text/event-stream";
export async function* readFromStream<T>(
response: Response,
Expand Down Expand Up @@ -30,7 +28,7 @@ export async function* readFromStream<T>(

try {
const chunk = data.replace("data:", "");
yield JSON.parse(decodeURIComponent(chunk), deserializeUint8Array);
yield JSON.parse(decodeURIComponent(chunk));
} catch (_err) {
console.log("error parsing data", _err, data);
continue;
Expand All @@ -43,7 +41,6 @@ export async function* readFromStream<T>(
try {
yield JSON.parse(
decodeURIComponent(buffer.replace("data:", "")),
deserializeUint8Array,
);
} catch (_err) {
console.log("error parsing data", _err, buffer);
Expand Down
28 changes: 0 additions & 28 deletions src/actors/util/buffers.ts

This file was deleted.

Loading