Skip to content

Commit e5f54c2

Browse files
authored
fix streams wpt piping/pipe-through.any.js (#5745)
1 parent efddd65 commit e5f54c2

File tree

7 files changed

+22
-48
lines changed

7 files changed

+22
-48
lines changed

src/workerd/api/streams/common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,12 @@ class ReadableStreamSource {
287287
};
288288

289289
struct PipeToOptions {
290-
jsg::Optional<bool> preventClose;
291290
jsg::Optional<bool> preventAbort;
292291
jsg::Optional<bool> preventCancel;
292+
jsg::Optional<bool> preventClose;
293293
jsg::Optional<jsg::Ref<AbortSignal>> signal;
294294

295-
JSG_STRUCT(preventClose, preventAbort, preventCancel, signal);
295+
JSG_STRUCT(preventAbort, preventCancel, preventClose, signal);
296296
JSG_STRUCT_TS_OVERRIDE(StreamPipeOptions);
297297

298298
// An additional, internal only property that is used to indicate

src/workerd/api/streams/readable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@ class ReadableStream: public jsg::Object {
267267
returnFunction,
268268
ValuesOptions);
269269
struct Transform {
270-
jsg::Ref<WritableStream> writable;
271270
jsg::Ref<ReadableStream> readable;
271+
jsg::Ref<WritableStream> writable;
272272

273-
JSG_STRUCT(writable, readable);
273+
JSG_STRUCT(readable, writable);
274274
JSG_STRUCT_TS_OVERRIDE(ReadableWritablePair<R = any, W = any> {
275275
readable: ReadableStream<R>;
276276
writable: WritableStream<W>;

src/wpt/streams-test.ts

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -85,25 +85,11 @@ export default {
8585
],
8686
},
8787
'piping/pipe-through.any.js': {
88-
comment: 'To be investigated',
89-
expectedFailures: [
90-
"pipeThrough should brand-check readable and not allow 'null'",
91-
"pipeThrough should brand-check readable and not allow 'undefined'",
92-
"pipeThrough should brand-check readable and not allow '0'",
93-
"pipeThrough should brand-check readable and not allow 'NaN'",
94-
"pipeThrough should brand-check readable and not allow 'true'",
95-
"pipeThrough should brand-check readable and not allow 'ReadableStream'",
96-
"pipeThrough should brand-check readable and not allow '[object ReadableStream]'",
97-
"pipeThrough should brand-check writable and not allow 'null'",
98-
"pipeThrough should brand-check writable and not allow 'undefined'",
99-
"pipeThrough should brand-check writable and not allow '0'",
100-
"pipeThrough should brand-check writable and not allow 'NaN'",
101-
"pipeThrough should brand-check writable and not allow 'true'",
102-
"pipeThrough should brand-check writable and not allow 'WritableStream'",
103-
"pipeThrough should brand-check writable and not allow '[object WritableStream]'",
104-
'pipeThrough should rethrow errors from accessing readable or writable',
105-
'pipeThrough() should throw if readable/writable getters throw',
106-
],
88+
comment: 'Windows has different property access order',
89+
expectedFailures:
90+
process.platform === 'win32'
91+
? ['pipeThrough() should throw if readable/writable getters throw']
92+
: [],
10793
},
10894
'piping/then-interception.any.js': {
10995
comment:
@@ -113,19 +99,7 @@ export default {
11399
'tee should not be observable',
114100
],
115101
},
116-
'piping/throwing-options.any.js': {
117-
comment: 'To be investigated',
118-
expectedFailures: [
119-
'pipeThrough should stop after getting preventAbort throws',
120-
'pipeThrough should stop after getting preventCancel throws',
121-
'pipeThrough should stop after getting preventClose throws',
122-
'pipeThrough should stop after getting signal throws',
123-
'pipeTo should stop after getting preventAbort throws',
124-
'pipeTo should stop after getting preventCancel throws',
125-
'pipeTo should stop after getting preventClose throws',
126-
'pipeTo should stop after getting signal throws',
127-
],
128-
},
102+
'piping/throwing-options.any.js': {},
129103
'piping/transform-streams.any.js': {},
130104

131105
'queuing-strategies-size-function-per-global.window.js': {

types/generated-snapshot/experimental/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2641,6 +2641,8 @@ interface Transformer<I = any, O = any> {
26412641
expectedLength?: number;
26422642
}
26432643
interface StreamPipeOptions {
2644+
preventAbort?: boolean;
2645+
preventCancel?: boolean;
26442646
/**
26452647
* Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.
26462648
*
@@ -2659,8 +2661,6 @@ interface StreamPipeOptions {
26592661
* The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set.
26602662
*/
26612663
preventClose?: boolean;
2662-
preventAbort?: boolean;
2663-
preventCancel?: boolean;
26642664
signal?: AbortSignal;
26652665
}
26662666
type ReadableStreamReadResult<R = any> =
@@ -2953,13 +2953,13 @@ declare abstract class TransformStreamDefaultController<O = any> {
29532953
terminate(): void;
29542954
}
29552955
interface ReadableWritablePair<R = any, W = any> {
2956+
readable: ReadableStream<R>;
29562957
/**
29572958
* Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use.
29582959
*
29592960
* Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
29602961
*/
29612962
writable: WritableStream<W>;
2962-
readable: ReadableStream<R>;
29632963
}
29642964
/**
29652965
* The **`WritableStream`** interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink.

types/generated-snapshot/experimental/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2649,6 +2649,8 @@ export interface Transformer<I = any, O = any> {
26492649
expectedLength?: number;
26502650
}
26512651
export interface StreamPipeOptions {
2652+
preventAbort?: boolean;
2653+
preventCancel?: boolean;
26522654
/**
26532655
* Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.
26542656
*
@@ -2667,8 +2669,6 @@ export interface StreamPipeOptions {
26672669
* The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set.
26682670
*/
26692671
preventClose?: boolean;
2670-
preventAbort?: boolean;
2671-
preventCancel?: boolean;
26722672
signal?: AbortSignal;
26732673
}
26742674
export type ReadableStreamReadResult<R = any> =
@@ -2961,13 +2961,13 @@ export declare abstract class TransformStreamDefaultController<O = any> {
29612961
terminate(): void;
29622962
}
29632963
export interface ReadableWritablePair<R = any, W = any> {
2964+
readable: ReadableStream<R>;
29642965
/**
29652966
* Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use.
29662967
*
29672968
* Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
29682969
*/
29692970
writable: WritableStream<W>;
2970-
readable: ReadableStream<R>;
29712971
}
29722972
/**
29732973
* The **`WritableStream`** interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink.

types/generated-snapshot/latest/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,6 +2545,8 @@ interface Transformer<I = any, O = any> {
25452545
expectedLength?: number;
25462546
}
25472547
interface StreamPipeOptions {
2548+
preventAbort?: boolean;
2549+
preventCancel?: boolean;
25482550
/**
25492551
* Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.
25502552
*
@@ -2563,8 +2565,6 @@ interface StreamPipeOptions {
25632565
* The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set.
25642566
*/
25652567
preventClose?: boolean;
2566-
preventAbort?: boolean;
2567-
preventCancel?: boolean;
25682568
signal?: AbortSignal;
25692569
}
25702570
type ReadableStreamReadResult<R = any> =
@@ -2857,13 +2857,13 @@ declare abstract class TransformStreamDefaultController<O = any> {
28572857
terminate(): void;
28582858
}
28592859
interface ReadableWritablePair<R = any, W = any> {
2860+
readable: ReadableStream<R>;
28602861
/**
28612862
* Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use.
28622863
*
28632864
* Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
28642865
*/
28652866
writable: WritableStream<W>;
2866-
readable: ReadableStream<R>;
28672867
}
28682868
/**
28692869
* The **`WritableStream`** interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink.

types/generated-snapshot/latest/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,6 +2553,8 @@ export interface Transformer<I = any, O = any> {
25532553
expectedLength?: number;
25542554
}
25552555
export interface StreamPipeOptions {
2556+
preventAbort?: boolean;
2557+
preventCancel?: boolean;
25562558
/**
25572559
* Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.
25582560
*
@@ -2571,8 +2573,6 @@ export interface StreamPipeOptions {
25712573
* The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set.
25722574
*/
25732575
preventClose?: boolean;
2574-
preventAbort?: boolean;
2575-
preventCancel?: boolean;
25762576
signal?: AbortSignal;
25772577
}
25782578
export type ReadableStreamReadResult<R = any> =
@@ -2865,13 +2865,13 @@ export declare abstract class TransformStreamDefaultController<O = any> {
28652865
terminate(): void;
28662866
}
28672867
export interface ReadableWritablePair<R = any, W = any> {
2868+
readable: ReadableStream<R>;
28682869
/**
28692870
* Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use.
28702871
*
28712872
* Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
28722873
*/
28732874
writable: WritableStream<W>;
2874-
readable: ReadableStream<R>;
28752875
}
28762876
/**
28772877
* The **`WritableStream`** interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink.

0 commit comments

Comments
 (0)