Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .changeset/puny-oranges-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@workflow/web-shared": patch
"@workflow/cli": patch
---

Add `Request` and `Response` revivers to web and CLI hydration so serialized Request/Response objects display correctly in the observability UI and CLI inspect output.
31 changes: 31 additions & 0 deletions packages/cli/src/lib/inspect/hydration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,37 @@ export function getCLIRevivers(): Revivers {
Float32Array: (value: string) => new Float32Array(reviveArrayBuffer(value)),
Float64Array: (value: string) => new Float64Array(reviveArrayBuffer(value)),
Headers: (value) => new Headers(value),
Request: (value) => {
// biome-ignore lint/complexity/useArrowFunction: arrow functions have no .prototype
const ctor = { Request: function () {} }.Request!;
const obj = Object.create(ctor.prototype);
Object.assign(obj, {
method: value.method,
url: value.url,
headers: new Headers(value.headers),
body: value.body,
duplex: value.duplex,
...(value.responseWritable
? { responseWritable: value.responseWritable }
: {}),
});
return obj;
},
Response: (value) => {
// biome-ignore lint/complexity/useArrowFunction: arrow functions have no .prototype
const ctor = { Response: function () {} }.Response!;
const obj = Object.create(ctor.prototype);
Object.assign(obj, {
status: value.status,
statusText: value.statusText,
url: value.url,
headers: new Headers(value.headers),
body: value.body,
redirected: value.redirected,
type: value.type,
});
return obj;
},
Int8Array: (value: string) => new Int8Array(reviveArrayBuffer(value)),
Int16Array: (value: string) => new Int16Array(reviveArrayBuffer(value)),
Int32Array: (value: string) => new Int32Array(reviveArrayBuffer(value)),
Expand Down
31 changes: 31 additions & 0 deletions packages/web-shared/src/lib/hydration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,37 @@ export function getWebRevivers(): Revivers {
Uint32Array: (value: string) => new Uint32Array(reviveArrayBuffer(value)),

Headers: (value) => new Headers(value),
Request: (value) => {
// biome-ignore lint/complexity/useArrowFunction: arrow functions have no .prototype
const ctor = { Request: function () {} }.Request!;
const obj = Object.create(ctor.prototype);
Object.assign(obj, {
method: value.method,
url: value.url,
headers: new Headers(value.headers),
body: value.body,
duplex: value.duplex,
...(value.responseWritable
? { responseWritable: value.responseWritable }
: {}),
});
return obj;
},
Response: (value) => {
// biome-ignore lint/complexity/useArrowFunction: arrow functions have no .prototype
const ctor = { Response: function () {} }.Response!;
const obj = Object.create(ctor.prototype);
Object.assign(obj, {
status: value.status,
statusText: value.statusText,
url: value.url,
headers: new Headers(value.headers),
body: value.body,
redirected: value.redirected,
type: value.type,
});
Comment thread
TooTallNate marked this conversation as resolved.
return obj;
},
URL: (value) => new URL(value),
URLSearchParams: (value) => new URLSearchParams(value === '.' ? '' : value),

Expand Down
Loading