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>(
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
6260export 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 {
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ export class AbortTaskRunError extends Error {
1919}
2020
2121export 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
Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments