File tree Expand file tree Collapse file tree 3 files changed +8
-10
lines changed Expand file tree Collapse file tree 3 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -54,14 +54,12 @@ export function runShapeStream<TRunTypes extends AnyRunTypes>(
54
54
url : string ,
55
55
options ?: RunShapeStreamOptions
56
56
) : RunSubscription < TRunTypes > {
57
- const subscription = new RunSubscription < TRunTypes > ( url , options ) ;
58
-
59
- return subscription . init ( ) ;
57
+ return new RunSubscription < TRunTypes > ( url , options ) ;
60
58
}
61
59
62
60
export class RunSubscription < TRunTypes extends AnyRunTypes > {
63
61
private abortController : AbortController ;
64
- private unsubscribeShape : ( ) => void ;
62
+ private unsubscribeShape ? : ( ) => void ;
65
63
private stream : AsyncIterableStream < RunShape < TRunTypes > > ;
66
64
private packetCache = new Map < string , any > ( ) ;
67
65
@@ -70,9 +68,7 @@ export class RunSubscription<TRunTypes extends AnyRunTypes> {
70
68
private options ?: RunShapeStreamOptions
71
69
) {
72
70
this . abortController = new AbortController ( ) ;
73
- }
74
71
75
- init ( ) : this {
76
72
const source = new ReadableStream < SubscribeRunRawShape > ( {
77
73
start : async ( controller ) => {
78
74
this . unsubscribeShape = await zodShapeStream (
@@ -108,8 +104,6 @@ export class RunSubscription<TRunTypes extends AnyRunTypes> {
108
104
controller . enqueue ( run ) ;
109
105
} ,
110
106
} ) ;
111
-
112
- return this ;
113
107
}
114
108
115
109
unsubscribe ( ) : void {
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ export class AbortTaskRunError extends Error {
19
19
}
20
20
21
21
export class TaskPayloadParsedError extends Error {
22
+ public readonly cause : unknown ;
23
+
22
24
constructor ( cause : unknown ) {
23
25
const causeMessage = cause instanceof Error ? cause . message : String ( cause ) ;
24
26
Original file line number Diff line number Diff line change @@ -32,11 +32,13 @@ export class SubtaskUnwrapError extends Error {
32
32
33
33
constructor ( taskId : string , runId : string , subtaskError : unknown ) {
34
34
if ( subtaskError instanceof Error ) {
35
- super ( `Error in ${ taskId } : ${ subtaskError . message } ` , { cause : subtaskError } ) ;
35
+ super ( `Error in ${ taskId } : ${ subtaskError . message } ` ) ;
36
+ this . cause = subtaskError ;
36
37
this . name = "SubtaskUnwrapError" ;
37
38
} else {
38
- super ( `Error in ${ taskId } ` , { cause : subtaskError } ) ;
39
+ super ( `Error in ${ taskId } ` ) ;
39
40
this . name = "SubtaskUnwrapError" ;
41
+ this . cause = subtaskError ;
40
42
}
41
43
42
44
this . taskId = taskId ;
You can’t perform that action at this time.
0 commit comments