Skip to content

Commit 8f04737

Browse files
committed
Fixing some typecheck errors
1 parent 0055dcf commit 8f04737

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

packages/core/src/v3/apiClient/runStream.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,12 @@ export function runShapeStream<TRunTypes extends AnyRunTypes>(
5454
url: string,
5555
options?: RunShapeStreamOptions
5656
): RunSubscription<TRunTypes> {
57-
const subscription = new RunSubscription<TRunTypes>(url, options);
58-
59-
return subscription.init();
57+
return new RunSubscription<TRunTypes>(url, options);
6058
}
6159

6260
export class RunSubscription<TRunTypes extends AnyRunTypes> {
6361
private abortController: AbortController;
64-
private unsubscribeShape: () => void;
62+
private unsubscribeShape?: () => void;
6563
private stream: AsyncIterableStream<RunShape<TRunTypes>>;
6664
private packetCache = new Map<string, any>();
6765

@@ -70,9 +68,7 @@ export class RunSubscription<TRunTypes extends AnyRunTypes> {
7068
private options?: RunShapeStreamOptions
7169
) {
7270
this.abortController = new AbortController();
73-
}
7471

75-
init(): this {
7672
const source = new ReadableStream<SubscribeRunRawShape>({
7773
start: async (controller) => {
7874
this.unsubscribeShape = await zodShapeStream(
@@ -108,8 +104,6 @@ export class RunSubscription<TRunTypes extends AnyRunTypes> {
108104
controller.enqueue(run);
109105
},
110106
});
111-
112-
return this;
113107
}
114108

115109
unsubscribe(): void {

packages/core/src/v3/errors.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export class AbortTaskRunError extends Error {
1919
}
2020

2121
export class TaskPayloadParsedError extends Error {
22+
public readonly cause: unknown;
23+
2224
constructor(cause: unknown) {
2325
const causeMessage = cause instanceof Error ? cause.message : String(cause);
2426

packages/core/src/v3/types/tasks.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ export class SubtaskUnwrapError extends Error {
3232

3333
constructor(taskId: string, runId: string, subtaskError: unknown) {
3434
if (subtaskError instanceof Error) {
35-
super(`Error in ${taskId}: ${subtaskError.message}`, { cause: subtaskError });
35+
super(`Error in ${taskId}: ${subtaskError.message}`);
36+
this.cause = subtaskError;
3637
this.name = "SubtaskUnwrapError";
3738
} else {
38-
super(`Error in ${taskId}`, { cause: subtaskError });
39+
super(`Error in ${taskId}`);
3940
this.name = "SubtaskUnwrapError";
41+
this.cause = subtaskError;
4042
}
4143

4244
this.taskId = taskId;

0 commit comments

Comments
 (0)