@rivetkit/cloudflare-workers 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import type { Context as HonoContext } from "hono";
2
- import type { Encoding } from "rivetkit";
2
+ import type { Encoding, UniversalWebSocket } from "rivetkit";
3
3
  import {
4
4
  type ActorOutput,
5
5
  type CreateInput,
@@ -9,7 +9,7 @@ import {
9
9
  HEADER_AUTH_DATA,
10
10
  HEADER_CONN_PARAMS,
11
11
  HEADER_ENCODING,
12
- HEADER_EXPOSE_INTERNAL_ERROR,
12
+ type ManagerDisplayInformation,
13
13
  type ManagerDriver,
14
14
  } from "rivetkit/driver-helpers";
15
15
  import { ActorAlreadyExists, InternalError } from "rivetkit/errors";
@@ -50,7 +50,8 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
50
50
  async sendRequest(actorId: string, actorRequest: Request): Promise<Response> {
51
51
  const env = getCloudflareAmbientEnv();
52
52
 
53
- logger().debug("sending request to durable object", {
53
+ logger().debug({
54
+ msg: "sending request to durable object",
54
55
  actorId,
55
56
  method: actorRequest.method,
56
57
  url: actorRequest.url,
@@ -67,10 +68,14 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
67
68
  actorId: string,
68
69
  encoding: Encoding,
69
70
  params: unknown,
70
- ): Promise<WebSocket> {
71
+ ): Promise<UniversalWebSocket> {
71
72
  const env = getCloudflareAmbientEnv();
72
73
 
73
- logger().debug("opening websocket to durable object", { actorId, path });
74
+ logger().debug({
75
+ msg: "opening websocket to durable object",
76
+ actorId,
77
+ path,
78
+ });
74
79
 
75
80
  // Make a fetch request to the Durable Object with WebSocket upgrade
76
81
  const id = env.ACTOR_DO.idFromString(actorId);
@@ -79,7 +84,6 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
79
84
  const headers: Record<string, string> = {
80
85
  Upgrade: "websocket",
81
86
  Connection: "Upgrade",
82
- [HEADER_EXPOSE_INTERNAL_ERROR]: "true",
83
87
  [HEADER_ENCODING]: encoding,
84
88
  };
85
89
  if (params) {
@@ -91,10 +95,7 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
91
95
  // Use the path parameter to determine the URL
92
96
  const url = `http://actor${path}`;
93
97
 
94
- logger().debug("rewriting websocket url", {
95
- from: path,
96
- to: url,
97
- });
98
+ logger().debug({ msg: "rewriting websocket url", from: path, to: url });
98
99
 
99
100
  const response = await stub.fetch(url, {
100
101
  headers,
@@ -107,7 +108,8 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
107
108
  );
108
109
  }
109
110
 
110
- logger().debug("durable object websocket connection open", {
111
+ logger().debug({
112
+ msg: "durable object websocket connection open",
111
113
  actorId,
112
114
  });
113
115
 
@@ -122,7 +124,7 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
122
124
  (webSocket as any).dispatchEvent(event);
123
125
  }, 0);
124
126
 
125
- return webSocket as unknown as WebSocket;
127
+ return webSocket as unknown as UniversalWebSocket;
126
128
  }
127
129
 
128
130
  async proxyRequest(
@@ -130,7 +132,8 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
130
132
  actorRequest: Request,
131
133
  actorId: string,
132
134
  ): Promise<Response> {
133
- logger().debug("forwarding request to durable object", {
135
+ logger().debug({
136
+ msg: "forwarding request to durable object",
134
137
  actorId,
135
138
  method: actorRequest.method,
136
139
  url: actorRequest.url,
@@ -150,7 +153,8 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
150
153
  params: unknown,
151
154
  authData: unknown,
152
155
  ): Promise<Response> {
153
- logger().debug("forwarding websocket to durable object", {
156
+ logger().debug({
157
+ msg: "forwarding websocket to durable object",
154
158
  actorId,
155
159
  path,
156
160
  });
@@ -166,7 +170,8 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
166
170
  const newUrl = new URL(`http://actor${path}`);
167
171
  const actorRequest = new Request(newUrl, c.req.raw);
168
172
 
169
- logger().debug("rewriting websocket url", {
173
+ logger().debug({
174
+ msg: "rewriting websocket url",
170
175
  from: c.req.url,
171
176
  to: actorRequest.url,
172
177
  });
@@ -183,7 +188,6 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
183
188
  }
184
189
 
185
190
  // Add RivetKit headers
186
- actorRequest.headers.set(HEADER_EXPOSE_INTERNAL_ERROR, "true");
187
191
  actorRequest.headers.set(HEADER_ENCODING, encoding);
188
192
  if (params) {
189
193
  actorRequest.headers.set(HEADER_CONN_PARAMS, JSON.stringify(params));
@@ -230,7 +234,7 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
230
234
  > {
231
235
  const env = getCloudflareAmbientEnv();
232
236
 
233
- logger().debug("getWithKey: searching for actor", { name, key });
237
+ logger().debug({ msg: "getWithKey: searching for actor", name, key });
234
238
 
235
239
  // Generate deterministic ID from the name and key
236
240
  // This is aligned with how createActor generates IDs
@@ -243,7 +247,8 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
243
247
  });
244
248
 
245
249
  if (!actorData) {
246
- logger().debug("getWithKey: no actor found with matching name and key", {
250
+ logger().debug({
251
+ msg: "getWithKey: no actor found with matching name and key",
247
252
  name,
248
253
  key,
249
254
  actorId,
@@ -251,7 +256,8 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
251
256
  return undefined;
252
257
  }
253
258
 
254
- logger().debug("getWithKey: found actor with matching name and key", {
259
+ logger().debug({
260
+ msg: "getWithKey: found actor with matching name and key",
255
261
  actorId,
256
262
  name,
257
263
  key,
@@ -337,4 +343,11 @@ export class CloudflareActorsManagerDriver implements ManagerDriver {
337
343
  key: actorData.key,
338
344
  };
339
345
  }
346
+
347
+ displayInformation(): ManagerDisplayInformation {
348
+ return {
349
+ name: "Cloudflare Workers",
350
+ properties: {},
351
+ };
352
+ }
340
353
  }